Skip to content

Prune record-free applications from the relevant level's tree; cache paths and locations - #39

Merged
handrews merged 1 commit into
mainfrom
claude/json-schema-engine-perf-67e40a
Oct 12, 2026
Merged

handrews merged 1 commit into
mainfrom
claude/json-schema-engine-perf-67e40a

Conversation

@handrews

Copy link
Copy Markdown
Owner

The relevant level of list, hierarchical and detailed built the whole located tree and then left most of it out: hierarchical/list omit a unit with nothing to report and detailed condenses one away. to_render_node now takes prune_empty and, for that level, drops every application with no record at or below it (the root always remains), deciding bottom-up so a pruned application never materializes a location. The verbose level and trace still take the whole tree. The walk keeps two frames per level, which the assembly backstop test relies on.

PathNode caches its materialized path and SchemaRef its location, both filled lazily on the frozen instance the way Cursor fills its pointer; a keyword's plain and fragment-encoded suffix is built once per name (output.keyword_suffixes) and shared by the unit renderers and the draft-03 tree. Documents are unchanged.

Measured on CPython 3.12: relevant-level list 35-45% faster on large, mostly record-free evaluations (bench: compiled evaluator list 1.2-2.25x, interpreter list 1.07-1.43x ops/s across the corpora); verbose 16-20%. A third of a large verbose render is the cyclic collector, which the library leaves alone; DESIGN.md section 5 records both findings. One consequence: detailed through a compiled evaluator on a deep record-free chain now renders where the backstop used to raise.

…paths and locations

The relevant level of list, hierarchical and detailed built the whole
located tree and then left most of it out: hierarchical/list omit a unit
with nothing to report and detailed condenses one away. to_render_node
now takes prune_empty and, for that level, drops every application with
no record at or below it (the root always remains), deciding bottom-up
so a pruned application never materializes a location. The verbose level
and trace still take the whole tree. The walk keeps two frames per level,
which the assembly backstop test relies on.

PathNode caches its materialized path and SchemaRef its location, both
filled lazily on the frozen instance the way Cursor fills its pointer;
a keyword's plain and fragment-encoded suffix is built once per name
(output.keyword_suffixes) and shared by the unit renderers and the
draft-03 tree. Documents are unchanged.

Measured on CPython 3.12: relevant-level list 35-45% faster on large,
mostly record-free evaluations (bench: compiled evaluator list 1.2-2.25x,
interpreter list 1.07-1.43x ops/s across the corpora); verbose 16-20%.
A third of a large verbose render is the cyclic collector, which the
library leaves alone; DESIGN.md section 5 records both findings. One
consequence: detailed through a compiled evaluator on a deep record-free
chain now renders where the backstop used to raise.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@handrews
handrews merged commit 21af0d3 into main Oct 12, 2026
9 checks passed
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.

1 participant