Skip to content

Keep a page's revision vocabularies in its memory, not on the layer pages share - #6440

Merged
max-sixty merged 1 commit into
mainfrom
agent-ad3a96c7704699b3e
Nov 18, 2026
Merged

max-sixty merged 1 commit into
mainfrom
agent-ad3a96c7704699b3e

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

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 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. 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 $layer vocabulary is a shallow copy made per call. _Revisions and layer._Layers share 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.

This was written by Claude Code on behalf of max-sixty

…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_
@max-sixty
max-sixty merged commit bfba673 into main Nov 18, 2026
5 checks passed
@max-sixty
max-sixty deleted the agent-ad3a96c7704699b3e branch November 18, 2026 23:44
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