Files
rustfs/docs/operations/local-batch-cpu-diagnostics.md
T
Henry Guo 9e57f83885 feat(storage): add opt-in EC layouts and frame-aware local reads (#9255)
* perf(ecstore): reduce allocations for bounded bitrot frames

* test(s3): cover dynamic block layouts over HTTP

* perf: measure quantized range read shape

* chore: checkpoint quantized read metrics draft

Save work in progress for collaboration. Counts omit retired readers and transient or cancelled hedges. Frame semantics, async recorder coverage and disabled-metrics overhead remain unresolved; these counters are not ready for performance conclusions.

Validation: rustfmt and ecstore check passed; io-metrics 120, quantized 4 and hashed-read 3 tests passed. No new live or performance validation.

* perf(ecstore): reduce dynamic layout read overhead

* fix(ecstore): avoid prefetching conservative short range tails

* perf(ecstore): compact deferred shard reader state

* perf(ecstore): include shard checksums in file buffer cap

* fix(ecstore): preserve bounded quantum frames during heal

* perf(ecstore): reuse owned quantized frame batches

* perf(ecstore): batch q reads and retain shared copy framing

* fix(ecstore): preserve typed quantized read errors

* perf(ecstore): avoid zero-fill and serial copies in local batch reads

The local batch reader zero-initialized every window at a nonzero offset
before reading it, and copied every shard serially inside one blocking
task. Two-segment q-window range reads (cross-shard, cross-block) pay
both costs twice per request.

Read each window with a positioned read into uninitialized Vec capacity,
and dispatch each shard separately when every window is at least 512 KiB,
where copies dominate blocking-pool round trips. Smaller windows keep one
coalesced dispatch.

* perf(ecstore): keep readahead pipelined for local batch windows

A single window-sized pread on cold pages waits on each kernel readahead
chunk in turn. Seek to the window start and fill the buffer with
read_to_end over a length-limited reader instead: it still reads into
uninitialized spare capacity, but its growing sequential reads keep
readahead pipelined. Warm windows cost the same.

* Revert "perf(ecstore): keep readahead pipelined for local batch windows"

This reverts commit c252fca525.

On the ESSD-backed cloud footprint, the growing read_to_end reads were
slower than one window-sized positioned read for cold windows at nonzero
offsets (cross-block -27% on 4 MiB layouts, cross-shard -21% on 64 KiB
layouts versus the previous batch reader). The local benchmark that
motivated the change ran on a WSL virtual disk and did not represent the
target storage. Keep the single positioned read into spare capacity and
the per-shard dispatch for large windows.

* perf(ecstore): choose the batch read method by window size

Measured on ESSD-backed cloud storage, a cold window of about 1 MiB is
fastest as one positioned read, which completes as a single device
request, while windows of 2 MiB and more are faster with growing
sequential reads that keep readahead pipelined (one large read waits on
each readahead chunk in turn). Use one positioned read up to 1.5 MiB and
a seek plus length-limited read_to_end above it. Both paths read into
uninitialized spare capacity; per-shard dispatch for large windows is
unchanged.

* perf(ecstore): read local batch windows with an exact readahead hint

Kernel readahead sizes its first request from the read size. A cold
16 KiB window at offset 0 pulled 64-128 KiB, and a single 2 MiB read was
split into serial readahead chunks that cached almost twice the window,
which is why neither the single positioned read nor growing sequential
reads won for every window size on block storage.

Announce each window with POSIX_FADV_WILLNEED, which submits exactly the
window at once, and then fill the exact spare capacity with positioned
reads. This replaces the size-based choice between the two read methods.
The hint is advisory and its failure does not fail the read. A residency
test checks that cold reads cache only their window; it failed with the
hint disabled (a 5-page window cached 32 pages).

* perf(ecstore): use half-shard read quantum at 1 MiB EC layout

* revert(release): defer certification rollout for 1.0.5 (#9254)

Revert e5563e6004 only on release/1.0.5. Its trusted verifier workflow and immutable-candidate integration are not available yet. Restore the previous publication path under the approved release policy; retain the completed product regression and preview acceptance requirements.

* fix(ecstore): preserve legacy full-shard framing for default 1 MiB layout

* perf(ecstore): enable direct-memory GET and coalesce cross-shard range reads for bounded-quantum blocks

* chore(ecstore): remove unused schedule_bitrot_reader_task wrapper

* fix(ecstore): run delete-recovery discovery off the metadata lane

Bucket-wide delete-recovery discovery starts with the server and walks the
whole bucket tree in pages of up to 4096 entries, one lstat per entry. Each
page ran on the per-disk namespace queue's foreground lane, which has a
single worker and also serves GET metadata reads. On a cold tree a page
holds that worker for hundreds of milliseconds, so every GET on the disk
waits behind it until the walk finishes.

Run the page on the queue's sync lane instead, as the delete-transaction
inspection already does for the same reason. The namespace lease and the
page bounds are unchanged.

The regression test occupies the foreground lane and requires a discovery
page to complete within ten seconds; it times out without this change.

* test(ecstore): align read_appending rollback assertions on error

* fix: align multipart and EC read paths with current workspace APIs

---------

Co-authored-by: Xiaoyang Han <lux1an@qq.com>
Co-authored-by: Chris An <anzhengchao@gmail.com>
2026-11-19 00:48:49 +08:00

3.9 KiB

Sampled local batch CPU diagnostics

Use this when: separating sampled local EC batch allocation and filesystem wall time from worker CPU time in a default-off diagnostic build.

This diagnostic build separates allocation, metadata, open and positioned-read elapsed time from Linux thread CPU time. It preserves offsets, integrity checks and error handling. Windows below 512 KiB share one blocking dispatch per batch; when every window is at least 512 KiB, each shard is a separate dispatch and appears as its own diagnostic batch. On Linux each window is announced with POSIX_FADV_WILLNEED and then read with positioned reads into uninitialized buffer capacity, so the allocation stage contains no buffer initialization. The build does not qualify observation overhead.

Build separately from any frozen performance binary:

RUSTUP_TOOLCHAIN=stable cargo build --release --locked -p rustfs --bin rustfs \
  --features diagnostic-local-batch

The feature is absent from default builds. Even this diagnostic build records nothing until both the sample rate and the target filter are enabled:

export RUSTFS_DIAGNOSTIC_LOCAL_BATCH_SAMPLE_EVERY=64
export RUST_LOG=warn,rustfs_local_batch_diagnostic=trace

The rate is an integer in 1..=65536. Missing, zero or invalid values disable capture. Rate 64 selects one in every 64 submitted batches; rate 1 is intended only for small correctness probes. Restart to change the rate. Disabled or unselected batches create no timing records and read no diagnostic clocks. While recording is enabled, each external S3 request retains a bounded shared ID, including requests whose batches are not selected. This is diagnostic work and must be accounted for before any observation-cost claim.

Business fields contain a process-local batch ID, the bounded server-owned canonical request ID when propagated, worker PID/TID, shard index, sizes and timing. The RustFS feature also enables a matching JSON formatter policy: explicit root events on this fixed diagnostic target omit current/ancestor spans and parent-derived request ID aliases. No additional spans are allocated on the sampled I/O path. There are no variable-ID metric labels. Missing request context is reported as request_context=missing, never treated as a successful join. The standard logger may attach source-location and thread metadata. Its JSON format flattens business fields; readers must distinguish these fields from formatter metadata and reject inherited request spans.

Queue wait is elapsed time across the async/blocking boundary and has no thread CPU delta. Execution and per-shard stages run synchronously on one worker thread. CPU clock failure or unsupported platforms omit cpu_ns and report cpu_clock_status=unavailable; this is different from an available zero-duration measurement. Clock and logging work perturb diagnostic samples. Elapsed and CPU are measured separately and must not be assumed equal or subtracted without accounting for measurement overhead. Stage durations can overlap and per-shard samples differ from per-batch samples. When production batch-stage metrics are enabled, these timings also include their recording work. Keep that state in the provenance; they are not bare system-call durations.

shard_result reports requested and actually read bytes, including partial reads on error. Unattempted stages are absent; a zero-length shard has no read sample. Captured correlation and dispatch stay with a blocking worker even after its caller is cancelled.

Keep the diagnostic binary, source revision, feature, rate, filters and raw events distinct from baseline or acceptance artifacts. Do not log credentials, object/disk paths, request bodies or arbitrary client-supplied identifiers to add correlation. Request-level client association must use the server's canonical response ID. Diagnostic results locate hypotheses; they do not regrade failed A/A or ABBA runs.