Repository navigation
Compactions get their own queue on staging, 32 at once; units stay at 8 - #60
Merged
Merged
Conversation
The bulk queue went from 100 jobs at once to 8 on 2026-10-16, for commit units, which hold whole leaves. Compactions share that queue, and the commit compaction of 30M records has taken 10.5-12 h since. A merge holds about 12 MB and mostly waits on R2, so push.compact and push.compactPiece now go to underlay-staging-compact, which the bulk Worker consumes 32 at a time. push.commit, refs.compact*, prod and Node are unchanged.
Member
Author
|
Closing: the rest of the Crossref dump won't load in today's layout (stopped 2026-10-20), and |
Member
Author
|
Reopened: the rest of the Crossref dump, and possibly bigger collections, will be loaded on layout F. Upload compaction is unchanged on F (#61 only made the joined run index write once), so a 30M-record session would compact for ~10.5 h again. Ship after #61's staging deploy, as its own deploy, measured on the next large session. |
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.
Compactions (
push.compact,push.compactPiece) get their own queue on staging,underlay-staging-compact, which the bulk Worker consumes 32 at a time. Commit units stay on the bulk queue at 8.Why: on 2026-10-16 the bulk queue went from 100 jobs at once to 8 (#45, #46). The cut was for commit units, which hold whole leaves of 44–216 MB and kept running out of memory. Compaction shares that queue, so it dropped to 8 as well:
a4d41dc5(Oct 15)9f792eef(Oct 17)8870400e(Oct 19)#57 and #58 cut compaction's CPU about in half: about 53 CPU-minutes an hour on
9f792eef, about 30 on8870400e. Wall time only went from 12.2 h to 10.5 h. With 7 of 8 slots busy and the isolate's thread half idle, a merge now mostly waits on R2 range GETs, so more merges in flight should go nearly proportionally faster.A merge holds about 12 MB: the 4 MB prefetch budget plus two 4 MB parts (
runs.tsrunConfig). A unit holds whole leaves. That's why the two get different limits.Change:
jobs.ts:COMPACT_JOBSset.QueueJobstakes a third queue for those jobs, falling back to the bulk queue.enqueueBatchsends to each distinct queue once. The oldif (this.bulk === this.queue) breakwould send jobs twice once a third queue can fall back to the same object.worker.ts: an optionalJOBS_COMPACTbinding.wrangler.bulk.jsonc(staging): the producer binding, plus a consumer forunderlay-staging-compactwithmax_batch_size: 1,max_concurrency: 32,max_retries: 10and the same dead-letter queue.wrangler.jsonc(staging): the producer binding. Uploads queue compactions from the main Worker (session.ts→maybeCompact).Unchanged:
push.commitstays on the bulk queue. When a compaction finishes, it claims the next round, and at the end it runs the commit. When no other push is in its units, a bulk slot frees within seconds, so it doesn't hold compaction back. If two pushes overlap, each round waits for one of the 8 slots. Moving the claim step to the compaction queue would be a follow-up.refs.compact*stay on the bulk queue.planCompactionchecks for a running compaction and then inserts one without a lock (the knownrefs.compactPartrace). Running more at once would make that worse.BULK_JOBS, so they keep their place in the order.Risks:
recover.ts) queues it again only once none of that session's compactions has moved for its window, and at most 100 per sweep. That's one more reason to halve at the first out-of-memory kills rather than wait.Deploy: after
8870400epublishes (about 03:00 UTC on Oct 20), not before. Frompackages/server:wrangler queues create underlay-staging-compactwrangler deploy -c wrangler.bulk.jsonc --env staging(this one consumes the new queue)wrangler deploy --env stagingThis deploy also brings #41 to the bulk Worker for the first time. #41 changes only how reads without
pointersresolve out-of-line records: they now look up to 16 entries or 4 MB ahead. Units and assembly read withpointers, which pass through unchanged.Metric:
exceededMemoryon compaction jobs.Rollback:
exceededMemoryin 15 minutes during compaction: setmax_concurrencyto 16 (config only).e12f49e9works, since older versions can't read raw runs.wrangler queues consumer remove underlay-staging-compact underlay-staging-bulk.Checked:
pnpm fmt:check,pnpm lint, and the servertypecheck.wrangler deploy --dry-runof both configs: both listJOBS_COMPACT.