Skip to content

Decode several months in parallel on a roomy host#12

Merged
tamnd merged 1 commit into
mainfrom
decode-concurrency
Jul 20, 2026
Merged

Decode several months in parallel on a roomy host#12
tamnd merged 1 commit into
mainfrom
decode-concurrency

Conversation

@tamnd

@tamnd tamnd commented Jul 20, 2026

Copy link
Copy Markdown
Owner

The zstd decoder was serialized to one month at a time by a global mutex, a guard against a small box holding two 2 GB decode windows at once. For a backlog of huge recent-year months that gate is the throughput wall: even with four process slots, giant dumps decode strictly one after another while the other slots idle.

This turns the gate into a counting semaphore sized from the budget:

  • ComputeBudget grants a second or third decode slot only when RAM can hold the extra 2 GB windows plus their conversions (budgeted at ~8 GB per decode slot), and never more than the process-slot count.
  • ARCTIC_MAX_DECODES overrides it for hand tuning and monitoring.
  • A small box still decodes strictly one at a time (unchanged default).
  • acquireDecoder captures the current gate so a later resize never routes a release to the wrong channel.

On a 23 GB / 8-core host this allows 2 concurrent decodes, roughly doubling throughput on a backlog of large months.

Tested: decode_gate_test.go covers the concurrency cap (peak == 2 at size 2), strict serialization at size 1, the zero-size floor, and the budget/override math. Full arctic package passes with -race.

The zstd decoder was gated to one month at a time by a global mutex, to
keep a small box from holding two 2 GB windows at once. That gate is the
throughput wall for a backlog of huge months: even with four process
slots, giant dumps decode strictly one after another.

Make the gate a counting semaphore sized from the budget. ComputeBudget
grants a second or third decode slot only when RAM can hold the extra
windows plus their conversions (about 8 GB per slot), never more than the
process slots. ARCTIC_MAX_DECODES overrides it for hand tuning. A small
box still decodes one at a time.
@tamnd
tamnd merged commit 38b0f23 into main Jul 20, 2026
6 of 7 checks passed
@tamnd
tamnd deleted the decode-concurrency branch July 20, 2026 04:30
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.

1 participant