Skip to content

perf(partitions): keep shard traffic moving during file I/O - #4311

Merged
hubcio merged 20 commits into
masterfrom
perf/task-per-partition
Oct 8, 2026
Merged

hubcio merged 20 commits into
masterfrom
perf/task-per-partition

Conversation

@hubcio

@hubcio hubcio commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Partition file writes and durability barriers held the shard pump,
delaying unrelated partitions until storage completed.

Run bounded, owned file jobs on the existing runtime and return
results to the pump for identity checks and ordered publication.
Keep commit, NoAck and lifecycle continuations with their owners.

Reserve job slots and retained bytes through result acceptance,
reuse consumer-offset descriptors and let replies progress when
file-job capacity is full. Drain outstanding work before repair,
transfer, purge, quarantine or shutdown.

Fence failed purge barriers, cancel obsolete checkpoint and retention
work before replacing history, and persist retirement barriers before
acknowledgment. Bound shutdown flushing by the WAL head, validate
commit headers in one pass and deliver completions locally.

Cover progress, capacity, stale completions, recovery and durability
failures with controlled I/O regressions and simulator purge tests.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Sep 28, 2026
@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.99725% with 364 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.49%. Comparing base (43fb443) to head (848411e).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
core/partitions/src/io.rs 84.68% 89 Missing and 55 partials ⚠️
core/partitions/src/segment_recovery.rs 65.60% 12 Missing and 42 partials ⚠️
core/shard/src/lib.rs 86.99% 28 Missing and 4 partials ⚠️
core/shard/src/router.rs 85.61% 19 Missing and 2 partials ⚠️
core/metadata/src/impls/metadata.rs 93.87% 7 Missing and 11 partials ⚠️
core/journal/src/prepare_journal.rs 92.15% 4 Missing and 8 partials ⚠️
core/partitions/src/persistence.rs 90.62% 10 Missing and 2 partials ⚠️
core/partitions/src/offset_storage.rs 94.91% 6 Missing and 3 partials ⚠️
core/consensus/src/impls.rs 90.12% 7 Missing and 1 partial ⚠️
core/server_common/src/fs_utils.rs 90.24% 2 Missing and 6 partials ⚠️
... and 16 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4311      +/-   ##
============================================
+ Coverage     87.54%   88.49%   +0.94%     
+ Complexity     1608     1607       -1     
============================================
  Files          1300     1302       +2     
  Lines        241253   251971   +10718     
  Branches     201557   212268   +10711     
============================================
+ Hits         211207   222981   +11774     
+ Misses        25014    23629    -1385     
- Partials       5032     5361     +329     
Components Coverage Δ
Rust Core 89.63% <90.10%> (+0.35%) ⬆️
Java SDK 68.81% <100.00%> (-0.02%) ⬇️
C# SDK 77.83% <ø> (+16.39%) ⬆️
Python SDK 91.25% <ø> (ø)
PHP SDK 85.67% <ø> (ø)
Node SDK 96.65% <100.00%> (+<0.01%) ⬆️
Go SDK 70.27% <50.00%> (-0.01%) ⬇️
C++ SDK 86.60% <ø> (ø)
Files with missing lines Coverage Δ
core/binary_protocol/src/consensus/header.rs 83.36% <ø> (ø)
core/common/src/error/iggy_error.rs 100.00% <ø> (ø)
core/configs/src/server_config/sharding.rs 95.93% <100.00%> (+0.75%) ⬆️
core/consensus/src/metadata_helpers.rs 95.14% <100.00%> (+0.06%) ⬆️
core/consensus/src/plane_helpers.rs 95.18% <100.00%> (-0.02%) ⬇️
core/journal/src/local_gate.rs 97.27% <100.00%> (+0.93%) ⬆️
core/journal/src/partition_journal/segments.rs 87.84% <100.00%> (-0.11%) ⬇️
core/metadata/src/impls/recovery.rs 84.80% <100.00%> (+0.08%) ⬆️
core/metadata/src/stm/result.rs 98.79% <100.00%> (+0.01%) ⬆️
core/metadata/src/stm/stream.rs 94.83% <100.00%> (+0.09%) ⬆️
... and 52 more

... and 83 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hubcio
hubcio force-pushed the perf/task-per-partition branch 2 times, most recently from c2065e3 to 14500cd Compare September 28, 2026 15:17
@hubcio

hubcio commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

/skill team-review-slim

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary: No correctness or data-loss defect: three warnings cover a missing wake in the partition I/O drain, a whole-queue scan on every ready pop, and a 256 MiB default that can never apply because one job's charge exceeds 4 GiB, plus five nits and four simplifications. Merge of four expert passes (storage, perf, distsys, ecosystem) with every anchor re-checked against the checkout.

Counts: critical 0, warning 3, nit 5, simplification 4

Findings without an anchor on a changed line:

  • core/partitions/src/iggy_partition.rs:4977 nit: New public I/O entry points such as history_is_busy, notify_io and has_io_dispatcher carry no doc comments, and the shard branches on their contracts. Add a one-line contract to each.

This review was generated by Claude Code 2.1.284 on deepseek-flash[1m]. Review the output before you act on it.

Comment thread core/partitions/src/io.rs Resolved
Comment thread core/shard/src/partition_io.rs Resolved
Comment thread core/shard/src/partition_io.rs Resolved
Comment thread core/shard/src/lib.rs Resolved
Comment thread core/shard/src/partition_io.rs Resolved
Comment thread core/shard/src/partition_io.rs Resolved
Comment thread core/shard/src/partition_io.rs Resolved
Comment thread core/shard/src/partition_io.rs Resolved
@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Sep 28, 2026
@hubcio
hubcio force-pushed the perf/task-per-partition branch 2 times, most recently from 1357156 to c30e383 Compare September 29, 2026 09:32
@hubcio

hubcio commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

don't merge or check this PR, it's way too convoluted right now.

@hubcio

hubcio commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

/skill team-review-slim

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary: Small findings only: a duplicated PartitionIoLimits conversion, an eager offset-file sync on a failed write, a dropped view message, and two doc gaps. The one performance warning about a capture-refusal spin was dropped after tracing showed the owner pump cannot build a capture plan while any file job is in flight, because resume_io returns Pending on io_active and only settle releases the gate.

Counts: critical 0, warning 0, nit 4, simplification 1

Findings without an anchor on a changed line:

  • core/partitions/src/iggy_partition.rs:5296 nit: defer_view_transition drops the incoming view message when the slot holds another transition, because only the View and empty arms store it. Document that retransmission recovers the round, or keep the newest message.

This review was generated by Claude Code 2.1.284 on deepseek-flash[1m]. Review the output before you act on it.

Comment thread core/server/src/boot/recovery.rs Resolved
Comment thread core/partitions/src/io.rs Resolved
Comment thread core/shard/src/lib.rs Resolved
Comment thread core/shard/src/builder.rs Resolved
@hubcio
hubcio force-pushed the perf/task-per-partition branch 2 times, most recently from 302cc4d to 50295e3 Compare October 7, 2026 10:10
hubcio added 12 commits October 7, 2026 19:22
Partition file writes and durability barriers held the shard pump.
Unrelated partitions waited until storage completed, and Replicated
commits also waited for the WAL writer and its checkpoints. On a
3-node cluster, Replicated p999 rose from 2-6 ms to 21-140 ms.

Run bounded, owned file jobs on the existing runtime and return
results to the pump for identity checks and ordered publication.
Commit, NoAck, purge, checkpoint and lifecycle continuations stay
with their owners, so durability and reply ordering hold.

A Replicated commit may pass a body the WAL writer has not written
yet, up to a 16 MiB backlog, and its flush takes only the written
prefix. Persisted commits wait while a WAL checkpoint is pending.
So do offset writes, because the checkpoint syncs the offset files
it lists. A session retirement follows partition durability.

Shutdown stops originating prepares, answers queued requests and
flushes committed ops. Each partition, a fatal one too, publishes
its WAL frontier before the drain. The tick now runs between job
phases, so it no longer extends the offset reservation during
shutdown or certifies the WAL during an install.

A state transfer pins its plan, so commits between rounds do not
restart the build. A receiver refuses only snapshots behind an op
it committed. Offset writes admitted before a purge get the
terminal errors of #4325.

Replicated p999 is back near master: 5.3 ms for 20 pinned
producers, 2.7 ms for one, 6.6 ms for producing consumers and
4.2 ms for balanced producers.

Add controlled I/O regressions for progress, capacity, stale
completions, lifecycle transitions, purge, shutdown, transfers
and Replicated run-ahead.
Failed purges could leave partially reset history serviceable, and
state transfer could reclaim the replacement receipt checkpoint.
File-job saturation also delayed unrelated replies, while shutdown
could wait beyond the WAL head.

Fence purge durability failures, cancel obsolete maintenance and
persist retirement barriers. Keep reply continuations runnable under
file-job saturation and validate commit headers in one journal pass.
Use local completion delivery, account for cleanup allocations and
align byte-limit configuration with other size settings. Add recovery
regressions and remove obsolete helpers.
No test failed when a dispatched Replicated commit ignored a due
checkpoint, or when a checkpoint covered a body that the WAL writer
did not write yet. Two tests hold the writer and check both waits.
Server test futures exceed Clippy's size limit on macOS arm64.
Pin the five affected futures on the heap without changing
production code or test behavior.
The offset-history fixture exceeds macOS Clippy's future size limit.
Box its nine test call sites without changing production execution.
Deferring repair replies as view transitions discarded valid prepares
while partition file jobs were busy, creating new gaps after repair.
Keep the existing repair completion barrier and check reply sessions
without fencing live replication. Cover held I/O and stale nonces.
Coalesced reference-WAL flushes left large gaps in the sparse index,
forcing each disk poll to scan an old prefix again. Bound index
spans to the existing 1 MiB save size, preserving body writes and
durability barriers. Cover backlog polling and checkpoint recovery.
Synchronous filesystem calls in metadata checkpoints, partition
recovery and statistics can stall every task on a shard.

Use Compio I/O and the bounded filesystem worker, retain cancellation
ordering, cache statistics and transfer offers, and sync dirty offset
directories. Preserve task-per-partition jobs and recovery barriers.

Capture metadata replay protection after snapshot I/O so concurrent
commits retain their sessions. Extend the regression to cover a
transferred table ahead of the local applied frontier.

(cherry picked from commit 202aefd9a28f551681cb0e3119851d2ac96a5559)
Compio snapshot I/O panics under the deterministic simulator executor.
Select synchronous snapshot I/O for simulator replicas while sharing
the durability sequence and retaining Compio for production. Cover
checkpoint replay with a deterministic schedule regression.
Dispatch could bypass durability holds, retain obsolete shutdown
intents, and finish purges with surviving bookmarks. Fence these
transitions, detach teardown handles from partition storage, and
preserve waiter order and reply batching. Add regressions covering
checkpoint and transfer holds, offset admission, and purge recovery.
Rust 1.99 flags empty-value assertions and overflows the default test
stack while constructing a large recovery fixture. Use diagnostic
assertions and heap-allocate the fixture's partition values without
changing the production path or increasing the test stack limit.
Pre-purge maintenance could delete new messages, and stalled file
jobs could keep the primary alive without making progress. Clear
obsolete retention, reject history-changed deletes and fence jobs at
the existing 30-second drain limit.

Keep independent consumer keys concurrent while retaining ordering,
batch offset writes and renames, publish replies in the commit turn,
and separate retries from ready completions. Index resident headers
and amortize eviction to avoid repeated scans and tail rebuilds.

Preserve offsets through failed install scans, use per-shard bounded
filesystem workers and retain deferred view messages per sender.
Leave transfer file jobs for a separate feature tracked by a TODO.
@hubcio
hubcio force-pushed the perf/task-per-partition branch from 50295e3 to c8b371b Compare October 7, 2026 17:22
The new server error 3014 left the Swift error table incomplete and
failed the golden-vector CI check. Add its Swift mapping and refresh
the generated fixture.
Comment thread core/partitions/src/journal.rs Resolved
Comment thread core/partitions/src/journal.rs Resolved
Comment thread core/shard/src/partition_io.rs Resolved
Comment thread core/partitions/src/io.rs Resolved
Comment thread core/partitions/src/iggy_partition.rs Resolved
Comment thread core/partitions/src/state_transfer.rs Resolved
Comment thread core/metadata/src/stm/stream.rs Resolved
Comment thread core/server/src/sysinfo_probe.rs Resolved
Comment thread core/shard/src/metrics.rs Resolved
Comment thread core/shard/src/partition_io.rs Resolved
hubcio added 7 commits October 7, 2026 22:59
Truncation retained stale header positions and could select the wrong
checksum during repair. Clear the index before replaying retained
entries and cover out-of-order repair plus duplicate operations.
An interrupted file job could leave its shutdown owner asleep until
the drain timed out. Notify the fenced owner without releasing its
held resources, and avoid rescanning owners while file jobs remain.
Go, Node and Java did not recognize the history-change error returned
by stale DeleteSegments requests. Add code 3014 to their existing
tables and pin its metadata result mapping with regression tests.
Interrupted file work could skip the WAL drain or its retries, and
late transfer and reconcile work could enter shutdown. Failed
batches and installs also left recovery state incomplete.

Drain accepted work with resources retained, close shutdown
admission, and preserve history and cleanup continuations. Cover
stale views, transfer retries, batch failures and retention. Expose
lane limits and fence counters, and record broader I/O follow-ups
without changing batching or deadline policy.
A partition could resolve segment offsets before applying an
already committed purge and turn a temporary lag into error 3014.
Compare owner history with metadata captured before the read.

Keep the committed history guard for purges after resolution,
including no-ops. Return HTTP 409 and document a fresh request
instead of replaying the committed rejection.
Continuing after sampler thread creation failed served the initial
system statistics forever. Propagate the failure before starting
shards so a running server always has the background sampler.
@hubcio
hubcio dismissed numinnex’s stale review October 8, 2026 09:03

everything from review fixed

Comment thread core/partitions/src/journal.rs Resolved
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.

4 participants