Skip to content

Count position-only records in the pump queue depth - #270

Open
serprex wants to merge 1 commit into
mainfrom
split/queue-depth
Open

serprex wants to merge 1 commit into
mainfrom
split/queue-depth

Conversation

@serprex

@serprex serprex commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Queue depth omits skipped records whose positions still occupy channel batches. Count positions in buffered, queued and settling batches. Include skipped positions in fork fence and settle counts on errors.

Extracted from original #228 and based directly on main. Contains no changes from #226 or other extracted PRs.

Validation: cargo fmt --all -- --check, cargo clippy --workspace --all-targets --locked -- -D warnings, and cargo test --locked --lib source::queueing_record_sink (15 passed). Rebuild crate for each isolated diff.

Measured impact (2026-10-22)

Compared 65437d21a132d8310d78c8c3d7febaec34c642a2 against shared parent 151fd47cbd75ec7b9bc63ffe7040f049e702ecd0, with each PR built separately.

Result: position-only depth now reports expected 511 instead of 0. Queue timings have overlapping ranges; no clear CPU overhead or gain established.

Workload Base (reported records) PR (reported records) Median change
511 buffered position-only records 0.00 [0.00, 0.00] 511.00 [511.00, 511.00] n/a
Workload Base (ns/record) PR (ns/record) Median change
Skipped records 17.89 [17.09, 22.40] 17.52 [16.81, 18.33] -2.1%
Wanted records, empty payload 42.72 [40.31, 43.02] 42.33 [40.88, 47.33] -0.9%
Wanted records, 256-byte payload 51.15 [50.17, 54.70] 50.17 [48.42, 52.10] -1.9%
Wanted records, 4 KiB payload 124.24 [121.52, 129.40] 125.73 [118.70, 129.69] +1.2%

Accounting probe buffers 511 unwanted records without yielding or shipping batch (batch size 512): expected depth 511. Throughput workload uses 262,144 records per case, no-op downstream batch sink, queue capacity 131,072, and two Tokio runtime workers. Timing includes allocation, dispatch, close, and runtime shutdown. Measured functional benefit is correct position-only queue depth; throughput results describe overhead of accounting change.

AMD Ryzen 7 7840U; rustc 1.99.1; locked dependencies; optimized release builds; mimalloc 0.1.52. Seven trials per revision, alternating base/PR order, pinned to CPUs 2,4,6 (three physical cores). Values show median [min, max]; negative time changes mean less work or waiting. Local component measurements, without PostgreSQL or ClickHouse services.

The queueing sink ships records its inner sink does not want as a
count and a high-water LSN, so they occupy channel batches while adding
nothing to in_flight. walshadow_pump_queue_depth therefore undercounts
by the skipped share, and on the write-heavy repro read a few hundred
to about 1,500 records while the channel was full and the pump blocked
on it, hiding that the queue worker bounds the drain.

Count skipped records into in_flight as they ship and out as the worker
settles them, as processed already does. The fork fence, which waits
for in_flight to reach zero, now also waits for their positions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants