Repository navigation
perf: Map identity overrides, evaluate environment flags once per document refresh - #262
Merged
Merged
Conversation
Identity overrides segments are indexed by identifier, and each identity is evaluated with its own only, narrowed to its identifier. Evaluation cost no longer grows with the number of identity overrides. Environment flags are evaluated once per environment document. Refs #198
for more information, see https://pre-commit.ci
khvn26
marked this pull request as draft
October 16, 2026 17:41
This was referenced Oct 16, 2026
`SegmentOverridesIndex` is now the read-only mapping consumers take, so `SegmentOverridesMapping` goes. Indexes are built as dicts of a new `SegmentContexts` alias, which also shortens repeated annotations.
One type for every index, built or read: `dict` and the per-identity `ChainMap` are both mutable mappings.
khvn26
marked this pull request as ready for review
October 19, 2026 11:06
emyller
requested changes
Oct 20, 2026
emyller
left a comment
Contributor
There was a problem hiding this comment.
Looks solid in its logic. Left a few comments that aim to contribute to interface and sticking to testing patterns.
I'd also advise against using base to name anything. It does not add meaning.
The client kept the evaluation context next to the `LocalEvaluation` built from it. It now keeps the `LocalEvaluation` only, whose `context` is the context without identity overrides segments, formerly `base_context`. Identity overrides segments are kept apart, by key. Also drops name mangling, as `__evaluation_context` goes.
`map_identifiers_to_identity_overrides_rules` built a single rule, so it is now `map_identifiers_to_identity_overrides_rule`, returning that rule.
Identity overrides conditions are typed as `InOperatorSegmentCondition` where they are built, and identifiers are read back as such, rather than cast to a list of strings with a comment.
Replaces comments explaining what the keys are.
Also drops `base` from test and variable names.
khvn26
force-pushed
the
perf/local-eval-regression
branch
from
October 20, 2026 14:39
3e37352 to
8fd7a17
Compare
Identity overrides were mapped to segments, one per unique set of overrides, merged into the evaluation context, then picked back out of it by `LocalEvaluation` and narrowed to an identity on every evaluation. They are now mapped straight from the environment document to a segment per identifier, kept out of the evaluation context. `LocalEvaluation` indexes each one's overrides once per environment document, so an identity evaluation only adds its own segment.
Drops comments, shortens the `LocalEvaluation` docstring, and specs the `LocalEvaluation` mocks in streaming manager tests.
Member
Author
|
Updated the logic to map env doc's |
emyller
approved these changes
Oct 21, 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.
Contributes to #198.
In this PR, we resolve two performance regressions in local evaluation mode, both dating from the move to the evaluation context engine (4.0.0/5.0.0).
Evaluation state now lives in a new
LocalEvaluationobject, rebuilt on every environment document refresh.Environment flags and single identity flags are now well ahead of 3.8.0.
An
all_flags()call for an identity is still 7–18% slower than 3.8.0; the remaining gap will be closed engine-side.Benchmark: gist