-
Notifications
You must be signed in to change notification settings - Fork 0
perf: investigate export rule evaluation performance (~100ms per rule per MVO) #417
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestperformancePerformance optimisation workPerformance optimisation work
Milestone
Description
Summary
During sync, EvaluateExportRules takes ~100ms per export rule per MVO in a devcontainer environment. With 2 export rules, MVOs matching both rules take ~320ms. This is observable as [SLOW] diagnostic warnings in the worker logs.
Observed Timings (devcontainer, Scenario 8 Small)
- ~100ms: MVOs hitting 1 export rule (users)
- ~320ms: MVOs hitting 2 export rules, or groups with multi-valued member attributes
- The time is spread across multiple sub-operations (none individually exceed 100ms)
Breakdown
The per-rule cost is dominated by CreateAttributeValueChanges:
- DynamicExpresso expression evaluation — reflection/IL compilation per expression string
- MVO attribute dictionary building — iterating all MVO attributes to create expression context
- No-net-change detection — comparing each mapped attribute against cached target CSO values
- Multi-valued reference iteration — for group members, iterates each value individually
Potential Optimisations to Investigate
- Expression compilation caching — verify expressions are cached across MVOs within a sync run (not recompiled per MVO)
- Batch export evaluation — evaluate all MVOs against a rule in one pass rather than one MVO against all rules (may enable shared context)
- Skip no-net-change on first sync — when no target CSO exists (provisioning), there's nothing to compare against
- Attribute dictionary reuse — if the same MVO attributes are used across multiple export rules, the dictionary could be built once
Context
- On production hardware these are likely 20-50ms per rule — the devcontainer CPU constraint amplifies the cost
- This is not a bug — it's the inherent cost of expression-based attribute mapping with no-net-change detection
- Discovered during log review on 2026-03-17
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestperformancePerformance optimisation workPerformance optimisation work