Skip to content

improve performance of schema and position lookups during feature decoding#560

Merged
azahnen merged 2 commits into
masterfrom
memoize-lookups
Jul 10, 2026
Merged

improve performance of schema and position lookups during feature decoding#560
azahnen merged 2 commits into
masterfrom
memoize-lookups

Conversation

@cportele

Copy link
Copy Markdown
Contributor

The decoding context exposes schema(), pos(), parentPos() and parentSchemas() as @Value.Lazy, but @Value.Lazy is not cached on a @Value.Modifiable, so each call re-resolved the per-path lookups - a map lookup keyed by the path list - on the schema mapping.

Memoize the lookups on the context, keyed by a version counter on the path tracker that changes whenever the tracked path changes:

  • FeaturePathTracker gains a version counter and isEmpty();
  • the four accessors delegate to overridable per-path lookups that the modifiable context resolves once per path and reuses.

The real mapping getters are still called, so dynamic schema transformers remain in effect; output is unchanged.

…oding

The decoding context exposes schema(), pos(), parentPos() and
parentSchemas() as @Value.Lazy, but @Value.Lazy is not cached on a
@Value.Modifiable, so each call re-resolved the per-path lookups - a map
lookup keyed by the path list - on the schema mapping.

Memoize the lookups on the context, keyed by a version counter on the path
tracker that changes whenever the tracked path changes:

- FeaturePathTracker gains a version counter and isEmpty();
- the four accessors delegate to overridable per-path lookups that the
  modifiable context resolves once per path and reuses.

The real mapping getters are still called, so dynamic schema transformers
remain in effect; output is unchanged.
@cportele cportele requested a review from azahnen as a code owner June 29, 2026 11:30
@azahnen azahnen enabled auto-merge (squash) July 10, 2026 10:03
@azahnen azahnen merged commit c87afa1 into master Jul 10, 2026
3 checks passed
@azahnen azahnen deleted the memoize-lookups branch July 10, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants