Repository navigation
Sessions: the annotation carry walk jumps over older overlays - #3107
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: b2dd931 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
mattzcarey
force-pushed
the
slim/sessions-carry
branch
from
November 24, 2026 11:20
23dd697 to
955c572
Compare
mattzcarey
force-pushed
the
slim/sessions-carry
branch
from
November 24, 2026 11:42
955c572 to
b2dd931
Compare
mattzcarey
marked this pull request as ready for review
November 24, 2026 11:42
Contributor
🟡 agents import sizes: 1 entry point grew
Changed exports (1)
How this worksEach runtime export is bundled on its own, minified, and gzipped. Changes smaller than 100 B, or smaller than 1% and 1 KiB, are ignored. Growth over 10% or 5 KiB is marked 🔴. This report is informational and does not fail CI. The workflow artifact contains every measurement. Compared |
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.
When
addCompactionorcompact()stores an overlay in a session that has annotations, it looks for the newest annotation of each kind among what the overlay hides, to carry onto it. That walk went row by row from the overlay's end down to where the history continues, including every row already under an older overlay. The gate measured the second compaction of a 100,000-row session at 600,158 rows read with an annotation present, against 200,211 without. With #2773, every Think session with a context block has an annotation.Now the walk steps the way reads do. At a row where an older overlay applies (the newest one ending there with a known continuation), it takes that overlay's summary, which already carries the newest annotation of what it hid, and jumps to the overlay's continuation.
seqfalls along an ancestor chain, so the walk stops at the first row at or below the new overlay's continuation, even when a jump passes it.The doc comment on
internal_annotationsalso now says that an annotation an overlay carried stays on the overlay after the rows it came from are deleted, since the summary was written with them (the gate's note on #3061).Cost. Each step of the walk is one overlay probe and one message lookup: it carries the parent id in the walk's row, so it doesn't read the current row again. Measured in the Workers pool on a 15,000-row session with one annotation, before (#3061) / after:
On a deployment at 100,000 rows, rv-5 measured the nested compaction at 25% fewer rows. An earlier version of this PR looked up two rows per step and made the first compaction 17% dearer (352k against 302k). The rest of each count is the compaction's own checks, about 2 rows per stored row with or without annotations. The gate, deployed at 100,000 rows: the second
compact()with an annotation reads 200,263 rows, against 600,167 before (200,267 on main with #2773's real context records, at the root and in a facet). A first overlay over raw rows still reads about 6 rows per hidden row when the session has an annotation; there is no older overlay to jump over there.Tests ran:
annotations.test.ts"carries past an older overlay by its summary, not row by row" (90,010 rows before, under 60,000 here, and the first compaction under 61,000; the value is carried even after the annotated row is deleted), the sessions suite (183), and check.How to probe: on a deployment, seed a session with 100,000 rows and annotate one of them, then compact it twice with ranges that overlap, the second wider. Compare rows read by the second compaction against #3061, then check which annotation the second overlay carries.