Skip to content

feat(qwp): batch socket writes and wake ack waits on progress - #235

Merged
jerrinot merged 16 commits into
mainfrom
sm_qwp_net_batch_ports
Oct 28, 2026
Merged

jerrinot merged 16 commits into
mainfrom
sm_qwp_net_batch_ports

Conversation

@jerrinot

@jerrinot jerrinot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Faster pooled QWP/WebSocket ingestion. These are the parts of #234 that don't change sender behaviour; #234's commit window (commit_rows / commit_interval_ms), which merges frames on the client, is left out. No new
configuration keys and no protocol changes.

  • wait() / flush_and_wait no longer cost ~10 ms each. They wake on sender progress instead of polling: ~99 → ~6.7k batches/s per thread.
  • Faster async ingestion. Ready frames go out in 64 KiB socket writes instead of one write per frame, and the per-row work is lighter.
  • Fixed-size pools (sender_pool_min = sender_pool_max) no longer close and reopen idle connections.

Each flush is still its own QWP message, ACK and rejection.

rows/s, batch 1 main this PR
async, 1 thread 206k 1.76M
async, 16 threads 1.67M 2.74M
sync, 1 thread 99 6.7k
sync, 16 threads 1.56k 86k

Measured against a server with commit coalescing questdb/questdb#8110 Against current QuestDB master, async stays at the main level.

jovfer and others added 15 commits October 27, 2026 17:56
The background runner now opens a bounded send burst per step: ready SF
frames are handed to the transport back to back, and the blocking
transport encodes them into one buffer that reaches the socket in writes
of up to 64 KiB when the burst closes. Every QWP message keeps its own
WebSocket frame, wire sequence and ACK, so the server sees the same frame
stream as before; only the number of write syscalls changes. A failed
group write is recovered by the ordinary reconnect replay because the SF
log retains every frame until it is acknowledged.

Manual progress mode and test transports keep their immediate one-frame
writes through the trait defaults.

Extracted from the wire-batching part of PR #234 (commit 2bbdfea),
without the commit windows and frame splicer introduced there.

Co-authored-by: victor <victorgaoyh@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Background publication first tries a plain append to the already
allocated active segment. Only when that fails does it start the append
deadline and enter the rotation and backpressure loop, so the common
path no longer reads the clock or sets up a wait budget per flush.

Ported from PR #234 (commit 2bbdfea).

Co-authored-by: victor <victorgaoyh@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The sender error log publishes a pending flag; empty error polls read it
and return without taking the shared store mutex, which storage
maintenance may hold for a while. Both poll cursors must drain before the
flag clears, and a poisoned store still goes through the lock so the
poison surfaces.

Ported from PR #234 (commit 2bbdfea).

Co-authored-by: victor <victorgaoyh@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A pool with sender_pool_min equal to sender_pool_max cannot shrink, so
its entries no longer carry an idle timestamp and the reaper skips them
instead of timing them out and reopening the same connection.

Ported from PR #234 (commit 2bbdfea).

Co-authored-by: victor <victorgaoyh@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Buffer::clear keeps the validated schema, so a buffer that always writes
the same single table reuses it on the next table() call instead of
revalidating and hashing the name after every flush. A symbol column
with one distinct value no longer builds its hash index; the index is
created when a second value arrives, keeping the dictionary IDs intact
across rollback and clear.

Ported from PR #234 (commit 2bbdfea).

Co-authored-by: victor <victorgaoyh@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Each table buffer keeps its column schema already encoded as
(name, wire type) pairs, appended when a column is added and rebuilt
after a rollback truncates columns. The replay message copies it instead
of re-encoding every column name on every flush.

Ported from PR #234 (commits 40160af and 73634e9).

Co-authored-by: victor <victorgaoyh@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Pooled wait paths slept 10 ms between watermark checks. They now take
the runner's progress generation before each check and block on its
notifier until the next send, ACK, maintenance step or terminal error,
bounded by the same no-progress deadline. Unrelated notifications do not
extend the deadline; only watermark advancement resets it.

Ported from PR #234 (commits d9d9884 and 4dbaebb).

Co-authored-by: victor <victorgaoyh@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A terminal initial-connect failure that finds the shared store poisoned
now terminalizes the lifecycle and notifies the progress notifier before
the pending runner stops, so an event-driven boundary wait observes the
failure instead of sleeping to its deadline.

Ported from PR #234 (commit 5abf8c7).

Co-authored-by: victor <victorgaoyh@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Releasing the send cursor no longer forgets where it was. The cursor
keeps its frame sequence, offset and segment base as a hint, and the
next lookup in the same segment scans forward from that hint instead of
walking every frame from the segment header. A sender that keeps up with
publication releases the cursor at the tail after every frame, so this
turns a per-frame rescan into a constant-size step.

Ported from PR #234 (commit 3e2a418) without the splicer-specific
rewind, which has no counterpart on this branch.

Co-authored-by: victor <victorgaoyh@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@jerrinot
jerrinot requested a review from a team as a code owner October 28, 2026 16:40
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 36379da7-1772-457c-a19f-a2a8c8b3b315
Commits

Reviewing files that changed from the base of the PR and between ad449ee and dd1ad55.

Files selected for processing: 1
  • questdb-rs/src/tests/qwp_sender_pool.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The PR updates sender-pool idle tracking, QWP buffer metadata and lookup, and QWP/WebSocket store-and-forward behavior. It adds bounded background frame batching, progress-based waits, sender-error state checks, and tests for these paths.

Changes: Sender pool lifecycle

Layer / File(s) Summary
Pool idle state and reaping
questdb-rs/src/db.rs, questdb-rs/src/tests/qwp_sender_pool.rs
Pool entries use optional idle timestamps. Fixed-size pools do not mark store-and-forward entries as reapable, while returned direct senders receive timestamps. Borrow waiters and the reaper use separate condition variables. Tests cover manual and automatic reaping and fixed-size pool reuse.

QWP buffer metadata

Layer / File(s) Summary
Cached schema and replay
questdb-rs/src/ingress/buffer/qwp.rs
Table buffers retain encoded schemas for replay and rebuild schema metadata after rollback. Tests cover size hints, schema reuse, rollback, and clone rewinds.
Table and symbol lookup
questdb-rs/src/ingress/buffer/qwp.rs
Dirty tracking and table selection add fast paths. Symbol indexing starts when a second distinct symbol is added, with tests for promotion and rollback.

QWP/WebSocket sender

Layer / File(s) Summary
Store-and-forward submission and maintenance
questdb-rs/src/ingress/sender/qwp_ws_sfa_queue.rs
Active-segment submission can report insufficient space without rotating. Disk rotation defers while spare creation is in flight. Tests cover submission, spare creation, and cleanup.
Segment cursor scanning and release
questdb-rs/src/ingress/sender/qwp_ws_sfa_queue.rs, questdb-rs/src/ingress/sender/qwp_ws_sfa_segment.rs, questdb-rs/src/ingress/sender/qwp_ws_driver.rs
Send cursors can release segment references while retaining scan positions. Segment lookup accepts an optional starting boundary.
Segment CRC updates
questdb-rs/src/ingress/sender/qwp_ws_sfa_segment.rs
CRC updates use detected hardware instructions for supported short inputs and fall back to the crate implementation otherwise. Tests compare results across input lengths and seeds.
Background WebSocket frame batching
questdb-rs/src/ingress/sender/qwp_ws.rs, questdb-rs/src/ingress/sender/qwp_ws_batch.rs, questdb-rs/src/ingress/sender/qwp_ws_driver.rs, questdb-rs/src/ingress/sender.rs
The background runner sends bounded bursts through transport batch hooks. The blocking transport groups masked frames and flushes at the byte limit or burst end. Tests cover batching and replay after flush failures.
Progress waits and sender errors
questdb-rs/src/ingress/column_sender/sender.rs, questdb-rs/src/ingress/sender/qwp_ws.rs, questdb-rs/src/ingress/sender/qwp_ws_driver.rs, questdb-rs/src/tests/qwp_ws.rs
Store-and-forward waits use progress notifications instead of fixed polling sleeps. Sender-error polling checks a shared pending flag. Tests cover wait notifications, error handling, and stalled-connect cleanup.

Priority: Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant SyncQwpWsRunner
  participant QwpWsSendCore
  participant BlockingQwpWsTransport
  participant QwpWsBatch
  participant WebSocketStream
  SyncQwpWsRunner->>QwpWsSendCore: Begin batch and get byte budget
  SyncQwpWsRunner->>QwpWsSendCore: Send ready frames in the burst
  QwpWsSendCore->>BlockingQwpWsTransport: Send frame
  BlockingQwpWsTransport->>QwpWsBatch: Append masked frame
  SyncQwpWsRunner->>QwpWsSendCore: Finish batch
  QwpWsSendCore->>BlockingQwpWsTransport: Finish and flush batch
  BlockingQwpWsTransport->>QwpWsBatch: Flush buffered frames
  QwpWsBatch->>WebSocketStream: Write and flush encoded frames
Loading

Possibly related issues

  • questdb/c-questdb-client#229: The PR changes QWP buffer schema and replay state, which is related to the issue’s concern about retained column state and later frame size.
  • questdb/c-questdb-client#233: The PR adds rollback coverage for schema state after a failed row, but the summaries do not establish that it addresses terminal schema rejection.
  • questdb/c-questdb-client#231: The PR changes reconnect batching and replay behavior, but the summaries do not establish that it addresses reconnect behavior when the maximum duration is zero.

Possibly related PRs

Suggested reviewers: kafka1991, mtopolnik

Merge Risk: Minimal · up to dd1ad

The reviewed test changes do not introduce an identified merge-blocking risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main changes: batched socket writes and progress-based wakeups for acknowledgement waits.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 56 functions across 10 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Grouped background sends can put both the Chunk frame (bravo) and the
Arrow frame (charlie) on the dead socket in one burst before the runner
reads the close, so the dictionary mirror, and with it the catch-up on
the replacement endpoint, may already hold charlie. Replayed frames that
overlap the catch-up are the tolerated idempotent case, and the
data-frame assertions are unchanged.

The test accepted only alpha or alpha+bravo, so it failed intermittently
in the arrow cargo legs (mac cargo tests and the linux arrow/polars
version-range job in build 283902).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jerrinot

Copy link
Copy Markdown
Contributor Author

Reviewing PR #235 at level 3, head dd1ad55, base b3e60e2.

Verdict: approve with comments. There are no Critical findings, and the coverage-gap check passes. One Moderate item (an inert change in db.rs plus a test that doesn't exercise it) and three Minor items remain.

The PR moved during the review. It started at ad449ee5, and dd1ad558 was pushed while it ran; that commit only changes one test. The review was restarted on the new head. Diffing the two PR diffs shows nothing else changed, so the production analysis carries over.

Critical

None.

Moderate

M1. Fixed-size pool "never reap" change has no effect, and its new test passes without it

  • Problem: last_idle_at: Option<Instant> repeats a guard that already exists.
  • Net impact: none for users. It adds complexity, and the commit and the PR's auto-generated summary claim a pool behaviour change that doesn't happen.
  • Evidence: at dd1ad558, fixed_size_pool_reuses_sender_after_idle_timeout passes with db.rs reverted to base: 50/50 sequential and 40/40 concurrent runs, and the whole qwp_sender_pool module passes (194/194).
  • Where: questdb-rs/src/db.rs:446, 648, 3021, 3218-3220, 3247-3250; the test is at questdb-rs/src/tests/qwp_sender_pool.rs:6553.
  • Why it's inert: take_reapable_column_sender already returns None when state.total() <= inner.sender_pool_min (db.rs:3215).
    • total() counts free plus in-use senders, and the borrow and recovery paths both need a reservation below sender_pool_max to add one, so total() ≤ sender_pool_max.
    • When min == max, that guard fires every time, at base and at head, before last_idle_at is ever read.
    • A sensitivity check with that guard deleted makes the test fail. So the test can detect reaping; the new change just never decides the outcome.
  • Suggested fix: either drop the Option and keep Instant, leaving reaper_cv as it is, or describe the change as skipping clock reads. Keep the test as a guard on the existing invariant, not as coverage for this change.

Minor

m1. Two comments still describe one-write-per-frame behaviour

  • Problem: the mirror comment and the batch module doc no longer match how sends work.
  • Net impact: misleading for maintainers only. The catch-up behaviour itself is tolerated.
  • Evidence: qwp_ws_driver.rs:1303 says "The frame's delta is on the wire". A frame's symbols are now recorded when it enters the user-space batch, before any socket write. qwp_ws_batch.rs:27-29 says the server sees "exactly the frame stream it would have seen with one write per frame". After a reconnect that isn't true: the replacement server's catch-up can include symbols from frames the old socket never received. The new test comment at qwp_sender_pool.rs:2892 says so.
  • Why it's harmless:
    • Under parallel load, ad449ee5 failed the test in 723 of 960 runs, all with charlie in the catch-up; base failed 0 of about 3,100.
    • Limiting each burst to one frame dropped failures to 1 in 1,920.
    • In every run checked, the final server dictionary and the replayed data frames were the same at head and base. The overlap is the idempotent re-registration case the client's torn-dictionary guard already relies on.
  • Suggested fix: reword both comments to say the frame was handed to the transport (possibly an unwritten batch).

m2. Dead code

  • Problem: SfaSendCursor::released() (qwp_ws_sfa_queue.rs:2719) was added by this PR and has no callers.
  • Net impact: none.
  • Evidence: an exhaustive search found no call. The module-level #![allow(dead_code)] at line 25 hides the warning.
  • Suggested fix: delete it.

m3. PR metadata

  • Problem: the description is "tbd" plus the bot summary, and the title has a double space.
  • Net impact: reviewers and release notes get no statement of user impact.
  • Evidence:
    • The title uses feat(qwp): but the commits are perf, fix and test.
    • The body doesn't say what users see differently (grouped writes, waits that wake on progress) or that TestVsQuestDBMaster is the live-server gate.
    • The bot summary says "Sender pools better preserve and reuse senders, including across idle timeouts", which M1 shows is not a behaviour change.
  • Suggested fix: write a short human description and fix the title.

Adjacent findings

None proved.

Coverage map

  • Test gate: passes, 0 coverage gaps reported.
  • Every behavioural change has a test that runs in PR CI.
  • The fix commit 5069f54 has a regression test that fails if the fix is reverted. So do the burst, batch-failure replay, sender-error fast path and hot-spare backpressure changes.

Summary

  • Severity split: 0 Critical, 1 Moderate, 3 Minor. All four are in the diff; none is out-of-diff breakage.
  • Panic and overflow: questdb-rs-ffi builds use panic = "abort" in release and dev (questdb-rs-ffi/Cargo.toml:73-77). questdb-rs itself uses the default unwind, with overflow checks off in release. No new panic is reachable: the new expect in append_symbol sits behind dict.len() == 2.
  • Submodules: no pointer moved (questdb/ and corrosion/ unchanged).
  • Checked and found sound:
    • every early exit from the send burst;
    • the condvar-based boundary wait (every watermark or terminal path notifies after publishing);
    • the sender-error pending flag's ordering against the terminal lifecycle;
    • the hot_spare_creation_in_flight lifecycle;
    • send-cursor hint safety (segment bases are unique);
    • the cached schema, one-table reuse and lazy symbol index (wire bytes match base);
    • the CRC intrinsics, which match the crate for lengths 0–300 with three seeds.
  • Tradeoff not raised as a finding: disk SF appends now wait for the runner's in-flight spare segment instead of creating their own. With the default 30 s sf_append_deadline that is less disk I/O. With a very small deadline, an append that base completed by blocking can now time out at rotation. I didn't establish that as a regression.
  • CI:
    • At ad449ee5, two jobs (mac cargo tests and the linux arrow/polars version-range job) failed on mixed_sfa_namespace_survives_endpoint_failover_and_catch_up. That test's expectation predated grouped sends.
    • dd1ad558 updates it. Locally it passes 240/240 under 48-way stress, and the full lib suite passes (2571 passed, 0 failed).
    • CI on dd1ad558 was still pending when this was written, including TestVsQuestDBMaster. That job, not PR CI, is the live-server gate for the grouped-write change.

@jovfer

jovfer commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Reviewing PR #235 at level 3, head dd1ad55, base b3e60e2.

Verdict: approve with comments. No Critical findings, and the test gate passes. Please address Moderate 1 (fixed-size pool) and Moderate 2 (burst-path tests) in this PR. Moderate 3 and 4 are cheap and also belong here.

Critical

None.

Moderate

1. Fixed-size in-memory pools now keep over-cap senders forever

  • Problem: d635847 stops the reaper from trimming pooled senders above the cap.
  • Net impact: Fixed-size pools without sf_dir keep the extra connections and runner threads for their whole lifetime.
  • Evidence: The same probe test was run at both revisions. At b3e60e2, reap_idle() returns 1 and free drops 3→2. At dd1ad55, it returns 0 and free stays 3. With 4, 8 and 12 rounds of churn, head retains 6, 10 and 14 senders, while base trims back to 2.

Trigger. Configure sender_pool_min == sender_pool_max >= 2 with no sf_dir. Borrow two senders. Retire one while the other is still borrowed. Any of these retires it: BorrowedSender::drop_on_return(), returning a sender that went terminal (for example after a server rejection), or C questdb_db_drop_sender. Then borrow twice more. The pool now holds more senders than sender_pool_max, and at head they are never reaped. The retained count levels off at the peak number of senders the application held at once.

Why. The over-cap state comes from an older accounting bug in return_sfa_to_pool (questdb-rs/src/db.rs:3033):

let _release = release_slot.then_some(SenderSlotRelease { decrement_in_use: true, decrement_closing: true, .. });

bool::then_some evaluates its argument eagerly. In memory mode release_slot is false, so the temporary guard is built and dropped immediately. Its Drop decrements in_use a second time, and saturating_sub hides it. The cap check then lets later borrows open extra senders.

At base, the reaper repaired this after idle_timeout_ms, because entries above sender_pool_min carried an idle timestamp. This PR sets last_idle_at to None when min == max (db.rs:649, :3021), and take_reapable_column_sender never expires None. The excess therefore becomes permanent.

The commit message's premise ("cannot shrink … instead of timing them out and reopening the same connection") does not hold at base. With correct accounting, total() <= sender_pool_min already makes the reaper return early for fixed-size pools. So on a correctly counted pool, the only effect of the change is one skipped Instant::now() per return: about 13 ns per borrow-and-return in a microbenchmark. The new test fixed_size_pool_reuses_sender_after_idle_timeout also passes unchanged at base.

Fix (choose one):

  • (a) At db.rs:3033, use release_slot.then(|| SenderSlotRelease { .. }). I confirmed this experimentally: retiring one of two borrowed senders then leaves in_use == 1, and the pool never exceeds the cap. The same eager pattern is at db.rs:2611 (retire_stale_entry) and :3192 (reap_idle_senders). It is harmless there today because they do not decrement in_use, but they should get the same change. Fix (a) also makes the commit's premise true.
  • (b) Drop d635847.

In either case, add a regression test using the trigger above that asserts free_count() + in_use_count() <= sender_pool_max after the refill.

2. The background burst's failure handling and byte bound have no failing test

  • Problem: Three behaviours of the new burst code have no test: a failed grouped write, the batch reset on reconnect, and the 64 KiB bound.
  • Net impact: These are on the default QWP/WS path. A regression would silently duplicate data or terminalize the sender.
  • Evidence: At dd1ad55, the full --lib suite (2267 tests) passes with each mutation below applied. Public-API probes over a real socket show what each mutation does.
Mutation at dd1ad55 Full --lib suite Observed through the public API
Remove self.batch.clear() from BlockingQwpWsTransport::reconnect (qwp_ws_driver.rs:3255) passes Setup: memory or file SF, background mode, server resets the connection before a flush. The replacement connection receives the stale grouped data frame and then the replay: a byte-identical duplicate. The sender keeps reporting success. Without the mutation, exactly one copy arrives.
Map the batch write errors to TransportFailure::Terminal (qwp_ws_driver.rs:3384 flush, :3506 in-burst) passes The same reset makes the sender terminal ("Could not flush/send WebSocket batch: Broken pipe") instead of reconnecting and replaying.
Remove the byte bound while bytes < budget (qwp_ws.rs:1316) passes With frames continuously ready, the runner reads no ACK until the SF queue is full. A probe saw 1 ACK poll in 248 sends, against one every 16 sends at head.

Why the existing tests miss these:

  • threaded_runner_replays_frames_whose_batch_write_failed uses a fake transport that returns Disconnect itself, so it never exercises the production error mapping or the batch reset.
  • runner_step_sends_every_ready_frame_in_one_burst sends three tiny frames, so it never reaches the byte bound.

Suggested tests, all built on existing helpers:

  • Batch reset across reconnect. A driver test using connect_blocking_test_transport, upgrade_qwp_ws_test_connection and read_client_frame: begin_send_batch → send_frame("stale") → restart_connection → send_frame("fresh") → finish_send_batch. The second server connection must read only "fresh".
  • Error mapping. The same harness, with the server resetting the socket (SO_LINGER 0) before the write. Both finish_send_batch (small frame) and send_frame (frame over 64 KiB) must return TransportFailure::Disconnect.
  • Byte bound. A BurstRecordingTransport with a small budget (e.g. 20) and payloads first, second, third. The recorded bursts must be [[0, 1], [2]].

3. An indefinite durable wait depends on a single notification that no test checks

  • Problem: No test fails when the wake-up after a durable ACK goes missing.
  • Net impact: If that wake-up regressed, durable wait calls with no timeout would hang in C, C++ and Rust.
  • Evidence: At dd1ad55, suppressing the notify on the DurableAck response path still passes all 2267 tests. With it suppressed, wait(AckLevel::Durable, Duration::ZERO) stays blocked after the ACK is applied (still blocked at 12 s). Base returns in 5–15 ms.

wait_for_boundary (column_sender/sender.rs:2240) now parks on the runner's notifier. A zero timeout means no deadline. That covers:

  • qwp_sender_wait(..., 0, ...),
  • the C++ qwp_sender::wait() default,
  • Rust wait(level, Duration::ZERO).

With the default sf_durability, nothing else notifies an idle sender.

The code is correct today: the DurableAck response reaches the notify in finish_hot_response_progress (qwp_ws.rs:1529). The gap is in the test. pooled_boundary_wait_keeps_ok_and_durable_notifications_distinct (qwp_ws.rs:4860) still passes with that notify suppressed, just in 5.04 s instead of 0.03 s, because its final wait(Durable, 5s) wakes at its deadline and rechecks. Bound that last wait the way the ACK test is bounded: run it on a thread with a zero (or long) timeout, require it to return within about 2 s via a channel, and call notify_all to release it before asserting.

4. The PR description is a placeholder

  • Problem: The body is "tbd" plus an auto-generated summary, and the title type does not match the commits.
  • Net impact: Reviewers and release notes have no description of the user-visible changes.
  • Evidence: gh pr view 235 at dd1ad55.

Please describe the user-visible changes:

  • Background socket writes are grouped per runner step. Frame bytes and per-frame wire sequence are unchanged.
  • Pooled and column-sender waits now wake on runner progress instead of polling every 10 ms.
  • Disk SF rotation now waits for an in-flight hot spare instead of creating its own segment. With a very short sf_append_deadline_millis this can surface as "append timed out waiting for a prepared segment spare" where base succeeded. That was measured with a 1 ms deadline, not with 10 ms or the 30 s default.
  • The sender-pool reaper and condvar changes.

Also state that TestVsQuestDBMaster (green on this head) is the gate for the write-path change. The commits are all perf, fix or test, so consider a perf(qwp): … title, and drop the double space after the colon.

Minor

  • qwp_ws.rs:1336: the literal 14 repeats FRAME_OVERHEAD (qwp_ws_batch.rs:40). Make the constant pub(super) and use it.
  • qwp_ws_sfa_queue.rs:2719: SfaSendCursor::released() is never called. The module-level #![allow(dead_code)] hides the warning, so remove the method.
  • qwp_ws_driver.rs:3498: the batching path masks frames with rand::random(), while the per-frame path uses random_mask() (qwp_ws.rs:2127). Measured cost is 14.9 ns against 8.1 ns per frame. Reuse the helper.

Adjacent findings (not blocking; issue draft, not filed)

In-memory sender pools can exceed sender_pool_max after a sender is retired

  • Net impact: Pools without sf_dir and with sender_pool_max >= 2 open more connections than the cap.
  • Location: questdb-rs/src/db.rs:3033 (return_sfa_to_pool), introduced in 3bffcc9 (feat: columnar DataFrame ingest (Arrow / Polars / Pandas) + Arrow egress #153). The same eager then_some pattern is at :2611 and :3192.
  • Symptom: After drop_on_return(), a terminal return, or questdb_db_drop_sender while other senders are borrowed, in_use is undercounted. Concurrent borrows then succeed beyond the cap: 6 threads with max=2 held 6 senders at once. With min < max, the excess is trimmed after idle_timeout_ms.
  • Reachability: Through the public Rust and C APIs. Disk SF and max=1 are unaffected.
  • Suggested fix: Change then_some(...) to then(|| ...). Fixing Moderate 1 with option (a) closes this as well.
  • Severity if filed standalone: Moderate.

Coverage map

The test gate passes. There are 2 admitted coverage gaps (Moderate 2 and 3), both Moderate. The affected tests run in the PR CI cargo test --lib legs that enable sync-sender-qwp-ws.

Summary

  • Verdict: approve with comments. Address Moderate 1 and 2; Moderate 3 and 4 are cheap.

  • Severity: 0 Critical, 4 Moderate, 3 Minor. Of the Moderate findings, 1 is out-of-diff breakage (Implement optional authentication #1), 2 are coverage gaps (Missing cmake install section #2, Question/Bug: Support more than 6 significant digits #3) and 1 is documentation (Add const qualifier #4). Everything except Implement optional authentication #1 is in the diff.

  • Build profile:

    • questdb-rs-ffi uses panic = "abort" in both release and dev, so catch_unwind is a no-op there. questdb-rs unwinds. Overflow checks are off in release.
    • The new unsafe CRC intrinsics are guarded by runtime feature detection and match crc32c_append. That was checked on 602k random cases on aarch64; the Linux and Windows CI legs cover x86_64.
    • The new expect in append_symbol cannot be reached.
  • Submodules: no pointer moves.

  • Protocol and CI: Frame bytes and per-frame wire sequence are unchanged; only the write grouping changes. TestVsQuestDBMaster and the Enterprise e2e job are green on dd1ad55, as are all PR CI legs.

  • Performance claims, checked against base:

    Claim Head Base
    Loopback drain of 200k one-row frames through the pool 35 ms 830 ms (head uses about 17× less CPU)
    Send-cursor resume, 100 B frames, 4 MiB segment 41 ns per frame 71 µs per frame
    Serial CRC on inputs up to 256 B 2–8× faster than the crc32c crate —

    A differential fuzz of the buffer changes (300 seeds × 400 operations, including rollback, marker rewind, clear and clone) produced byte-identical replay output at base and head.

  • Tradeoffs:

    • Disk rotation now waits for an in-flight hot spare (see Moderate 4).
    • A parked pooled waiter now wakes on every sent frame and every ACK. That costs about 85 ns per frame compared with a 10 ms poll on a fast loopback server, and head is still far ahead of base end to end. A follow-up could notify a waiter only when its boundary is reached.

@jerrinot
jerrinot merged commit b0a8192 into main Oct 28, 2026
29 checks passed
@jerrinot
jerrinot deleted the sm_qwp_net_batch_ports branch October 28, 2026 18:43
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