feat: dirty-flag rule skip, mode-aware pruning, batch fact setter, condition cache#8
Merged
Conversation
…ndition cache Add four performance optimizations to the arbiter engine: 1. Dirty-flag rule skip (CONFIG_ARBITER_DIRTY_SKIP): - Track which facts changed via uint64_t dirty_mask in snapshot - Compute per-rule dependency bitmask at compile time - Skip rule evaluation when no dependent facts changed - Emit ARBITER_MODEL_RULE_DEPS in generated header 2. Mode-aware rule pruning: - Add required_mode field to ARBITER_rule_def - Compiler detects mode_guard rules with mode equality checks - Engine skips rules whose required_mode != current_mode - UINT16_MAX sentinel means 'evaluate in any mode' 3. Batch fact setter (ARBITER_set_facts): - Validate context once, then loop setting each fact - Returns ARBITER_OK or first error encountered - More efficient than N individual ARBITER_set_i32 calls 4. Condition result cache (CONFIG_ARBITER_COND_CACHE): - 8-entry cache in eval loop for repeated condition checks - Keyed by (fact_id, op, value) tuple - Reset each eval cycle - Helps when multiple rules test the same condition All existing tests pass (141 passed, 1 skipped). Co-Authored-By: Oz <oz-agent@warp.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Performance Optimizations
Add four performance optimizations to the arbiter engine:
1. Dirty-flag rule skip (CONFIG_ARBITER_DIRTY_SKIP)
2. Mode-aware rule pruning
3. Batch fact setter (ARBITER_set_facts)
4. Condition result cache (CONFIG_ARBITER_COND_CACHE)
Tests
All 141 tests pass, 1 skipped (golden vectors placeholder).
Conversation: https://app.warp.dev/conversation/cbbf5a9b-9163-44ac-8a72-ca91f2f49f74
Run: https://oz.warp.dev/runs/019e8993-e9ad-7e1b-b02b-d75ab0d24caf
This PR was generated with Oz.