Repository navigation
Skip decoding rule state without prefilter keys - #1023
Conversation
Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 15 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Performance Benchmark ResultsNode-Agent Resource Usage
Dedup EffectivenessNo data available. |
There was a problem hiding this comment.
🟢 Approval recommended
The optimization preserves existing behavior and is covered by focused regression tests.
0 open findings
What changed in this PR
Optimizes rule-state parsing by skipping unnecessary JSON decoding when no prefilter keys exist.
Changes:
- Detects all case-insensitive prefilter keys before decoding.
- Preserves JSON validation and mutable rule-state behavior.
- Adds regression tests and parsing benchmarks.
| File | Description |
|---|---|
pkg/rulemanager/prefilter/prefilter.go |
Adds the decode fast path. |
pkg/rulemanager/prefilter/parse_state_test.go |
Tests validation, key matching, mutations, and benchmarks. |
pkg/rulemanager/rulecreator/factory_prefilter_state_test.go |
Tests rule lifecycle and shared-state behavior. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Rules without prefilter keys currently marshal their state, decode it into
rawParams, and discard the empty result on each refresh. Skip the decoding step for validated JSON whose top-level keys cannot match a prefilter field.Keep merging, binding precedence, JSON validation, existing warning paths, and the invariant that nonnil
Paramshas an active filter. Matchencoding/jsonfield lookup withstrings.EqualFold, including Unicode cases such asportſ.json.Validkeeps decoder validation failures on the existing error path. No persistent cache is added: public rule state maps remain mutable, including through shallow result copies.Validation:
The parser accounted for only ~0.6% of allocation bytes in the latest short production profile. This is a small local improvement, not a promise of a measurable whole-agent memory reduction. The direct DigitalOcean five-minute smoke/profile run completed with matched image configuration, process ages, and workload placement, with zero frontend failures, workload restarts, or detected export/drop errors. Whole-agent allocation was lower, but the change was dominated by unchanged code and cannot be attributed to this shortcut. Working set was 4.3% higher; the 116 additional goroutines were existing ants pool workers. Sparse parser samples do not establish a production allocation improvement or regression. The newer v0.3.254-based private integration was separately tested; it was not the graph profiled on DO.