Repository navigation
perf: Serialise evaluation context and resolve JSONPaths once per evaluation - #43
Merged
Merged
Conversation
…luation Identity overrides are mapped to segments conditioned on `$.identity.identifier`. Each such condition re-parsed the JSONPath and serialised the whole evaluation context to JSON, so evaluating an identity cost O(identity overrides × context size). With 1,000 identity overrides and 1,000 features, a single evaluation took ~0.6–4.7s. Evaluate all segments through a shared `SegmentEvaluator` that serialises the context lazily, at most once, and caches the resolved value per JSONPath. The public `is_context_in_segment` keeps its signature.
matthewelwell
previously approved these changes
Oct 30, 2026
matthewelwell
approved these changes
Oct 30, 2026
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.
In this PR, we construct JSON paths at most once per evaluation.
Measured locally with the flagsmith-rust-client benchmarks, patched to this branch (median per call):
get_identity_flags_no_traitsget_identity_flags_with_traitsget_identity_segments_with_traitsget_environment_flagsThe remaining per-call cost on
largeis mostly the single context serialisation.