Repository navigation
perf(writer): let the backends report write completions directly - #144
Merged
greenhat616 merged 2 commits intoOct 21, 2026
Merged
greenhat616 merged 2 commits into
greenhat616 merged 2 commits into
Conversation
Each write of the download loop went through a spawned task that sent it to the backend's worker, awaited the worker's oneshot reply and forwarded the result to the loop's completion channel. `PendingWriter::new_direct` now queues the write straight to the mmap, pool, null or compio workers, with a `CompletionGuard` that the worker completes into that channel; only a full worker queue still takes a task, which queues the same guarded write. The guard enters the command before it is queued, so every write completes exactly once: done, dropped with its queue (a worker that exits now closes and drains it), with a panicking worker, or with a task that was never polled. The four backends share one `Command` type. `PendingWriter::new` keeps the spawned path for any `FileRangeWriter`, now with the same guard. The pool backend also syncs the file only after all its workers exited, so a write taken by one worker cannot land after another worker synced. Measured end to end with the mmap backend: 2-4% less user and system CPU.
- `TaskRunnerBuilder::connector` takes `impl Into<StreamConnector>`, so a connecting future can be passed as is; the docs of `stream`, `connect_timeout`, `StreamNotSet` and `TaskOptions::connect_timeout` say how they interact and that the singleton task's connection is now bounded by the connect timeout. - The native timer test measures from before the timers exist, and the coordination bench no longer requires a queue of one to fill, which depends on scheduling.
This was referenced Oct 16, 2026
greenhat616
marked this pull request as ready for review
October 21, 2026 06:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 13/13 of the event-loop optimization stack · Perf + review fixes. Stacked on part 12.
CompletionGuard(exactly once on every path) instead of spawn + oneshot; the pool backend syncs after all workers exit. End to end (10 GiB, mmap): user/sys CPU -2..-4% (two interleaved rounds, low confidence).