Repository navigation
Keep a page's revision vocabularies in its memory, not on the layer pages share - #6440
Merged
Merged
Conversation
…ages share Continues #6432, which kept a layer that reads a page's own package copy in that page's memory. A layer vocabulary of shared package roots is one object for every page that selects those packages, held for the process. Its `readings` dict gained entries for each page that read it: the vocabulary with the page's `$layer`, and each revision's composed vocabulary, a deep copy of the layer's registry. Both name the page's generation, so no other page read them, and nothing dropped them. A process that read 24 pages past the eight it keeps held 7.4 MiB, about 238 KiB more for each page read; it now holds 3.9 MiB at 24 pages or 64. A revision's vocabulary now lives in its page's memory (`registry.storage._Revisions`), beside the layer vocabulary it was composed over, and is composed again once `forget_layers` or a package install replaces that vocabulary. A page's revisions that declare the same still share one. The `$layer` vocabulary is no longer kept: it is a shallow copy made in tens of microseconds, and every caller in Leaf keeps what it composes from it. `LayerVocabulary.readings` is gone, and the keyed store `layer._Layers` held is now `page_memory.Stamped`, which both use. A sample now composes its own revision vocabulary rather than sharing its parent's: eight samples hold 2.8 MiB each rather than 2.6 MiB, and take no measurably longer to create (about 165 ms each either way). The new test fails against the old store, against a page store keyed by the layer vocabulary rather than kept beside it, and against one blind to the vocabulary. > _This was written by Claude Code on behalf of max-sixty_
leaf-agent
approved these changes
Nov 18, 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.
Continues #6432. A layer vocabulary of shared package roots is one object for every page that selects those packages, held for the process, and its
readingsdict gained entries for each page that read it: the vocabulary with the page's$layer, and each revision's composed vocabulary, a deep copy of the layer's registry. Both name the page's generation, so no other page read them, and nothing dropped them. After 24 pages past the eight a process keeps, it held 7.4 MiB, growing 238 KiB per page; it now holds 3.9 MiB at 24 or 64.A revision's vocabulary now lives in its page's memory (
registry.storage._Revisions), beside the layer vocabulary it was composed over, and is composed again once that is replaced. A page's revisions that declare the same still share one. The$layervocabulary is a shallow copy made per call._Revisionsandlayer._Layersshare one keyed store,page_memory.Stamped.A sample composes its own revision vocabulary instead of sharing its parent's, holding 2.8 MiB rather than 2.6 MiB.
The new test fails against the old store, a page store keyed by the vocabulary, and one blind to it.