Repository navigation
Conversation
…d entries count toward a writer's runs
… overlapping uploads; pack rows from write hooks
tefkah
marked this pull request as ready for review
October 21, 2026 20:09
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.
Stacked on #71 (the type cuts, onto
main: #68 merged intoupload-packsinstead). Merge #71 first, then point this atmain.Layout F gets leveled packs, so reading the current version stays about as cheap however many days of changes go in. This is "c3" from the daily-updates simulation: Layout F Daily Updates. The design note, in meta, is
planning/kf/underlay/leveled-packs-design.md. It's off by default:LEVELED_PACKS=1turns it on, and then only for collections that are empty at their first write.Measured locally (real code, scaled down about 1/64)
The measurement ran 200,000 records of about 500 B (102 MB), loaded in key order, then 120 days of 2,000 random changes each. It counts a cold read of 1,000 consecutive current records, 20 leaves per checkpoint, at the median. Packs were 256 KB and the smallest level target 4 MB. Script:
bench-leveled.mts, in the session folder.How it works
lo/hi). A leveled collection's packs also say their level, orhistorywith the month.manifest/f/levels/<id>.json, up to 512 packs each) that the manifest names with their key ranges.#mergeLevels, inmaintain):in_key_orderinto a new collection, goes there in one step, with no rewrite on the way down.manifest/f/leveled.json, written by the collection's first write whenLEVELED_PACKS=1(layoutConfig.levelNew) finds it empty. A fork gets it from its parent. A collection that already holds packs stays tiered, unchanged.Not in this PR
testing/,scale-testing), checked against the simulator, is the next measurement.Tests
test/repo/leveled.test.ts:UNDERLAY_TEST_LEVELED=1. Three tests gained layout-aware expectations: two write budgets (leveled adds the mark and a shard), and the upload test, where a leveled first load is the bottom level rather than the registry.Deploy
Migration
0028_push_pack_ranges(push_packs.lo_key,hi_key, nullable) goes with or before the deploy. The keys are stored as JSON strings: SQLite text ends at a key's first NUL (found building the index split; fixed here in 2c91484, with the upload test checking a bottom pack's range after it goes through the database).LEVELED_PACKSis"1"in both Workers' vars. Then new (empty) collections are leveled from their first write.levelMergesstat rises with commits; level 0 stays under 16 packs; leaf reads' pack GETs stay flat across dailies.LEVELED_PACKS. Leveled collections must then be read by this code: older code doesn't know shards and would miss level packs in reclaim. So a code rollback with leveled collections in place needs them deleted, or this PR kept.