future-util: opts#31061
Open
StephanDollberg wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes ssx future utility helpers to reduce overhead (scheduler round-trips / allocations) and adds a dedicated rpbench benchmark to measure ignore_shutdown_exceptions behavior across common success/failure paths.
Changes:
- Reworks
ssx::ignore_shutdown_exceptionsto fast-path already-ready successful futures and use a shared shutdown-exception filter. - Reimplements
ssx::spawn_with_gate_thento avoidtry_with_gateand filter shutdown exceptions in athen_wrappedcontinuation. - Adds
future_util_rpbenchbenchmark to exerciseignore_shutdown_exceptionswith ready-success, shutdown-failure, and non-shutdown-failure inputs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/v/ssx/future-util.h | Optimizes shutdown-exception filtering and gate-spawn helper to reduce overhead on common paths. |
| src/v/ssx/tests/future_util_bench.cc | Adds perf benchmarks focused on ignore_shutdown_exceptions fast path and exception filtering. |
| src/v/ssx/tests/BUILD | Registers a new rpbench target for the future-util benchmark. |
dotnwat
reviewed
Jul 9, 2026
dotnwat
left a comment
Member
There was a problem hiding this comment.
how much goose value does this add?
Cover already-resolved futures for success, gate closure, abort, and non-shutdown propagation. Keep producers out of line so callers cannot specialize for a known future state. Release/Bazel baseline (inst / tasks / allocs): ready 289 / 0 / 1 gate closed 22.87K / 0 / 3 abort 22.56K / 0 / 3 non-shutdown 24.44K / 0 / 4
Return already-successful futures directly. Handle failures with one
continuation that classifies once. Shutdown errors are swallowed; other
errors are returned in a failed future. This removes the coroutine frame
and a second unwind.
Release/Bazel deltas vs b0d4b296:
produce 1 KiB:
inst 56.13K -> 55.06K (-1.07K, -1.9%)
tasks 34 -> 34 (0, 0.0%); allocs 94 -> 90 (-4, -4.3%)
raft quorum ack, 16 B:
inst 159.82K -> 157.84K (-1.98K, -1.2%)
tasks 105 -> 105 (0, 0.0%); allocs 265 -> 254 (-11, -4.2%)
ready:
inst 289 -> 85 (-204, -70.5%)
tasks 0 -> 0 (0, 0.0%); allocs 1 -> 0 (-1, -100.0%)
gate closed:
inst 22.87K -> 15.50K (-7.37K, -32.2%)
tasks 0 -> 0 (0, 0.0%); allocs 3 -> 2 (-1, -33.3%)
abort requested:
inst 22.56K -> 15.19K (-7.37K, -32.7%)
tasks 0 -> 0 (0, 0.0%); allocs 3 -> 2 (-1, -33.3%)
non-shutdown:
inst 24.44K -> 17.30K (-7.14K, -29.2%)
tasks 0 -> 0 (0, 0.0%); allocs 4 -> 3 (-1, -25.0%)
Combine gate release and exception filtering in one then_wrapped
continuation. Return immediately when the gate is closed, and reuse the
shared shutdown filter on failure. Each successful call saves one task
and one allocation.
Release/Bazel deltas vs c23ee68:
produce 1 KiB:
inst 55.45K -> 55.30K (-150, -0.3%, noise)
tasks 34 -> 33 (-1, -2.9%); allocs 90 -> 89 (-1, -1.1%)
raft quorum ack, 16 B:
inst 157.82K -> 157.10K (-720, -0.5%, noise)
tasks 105 -> 100 (-5, -4.8%); allocs 253 -> 249 (-4, -1.6%)
future_util_rpbench:
all four cases unchanged in inst, tasks, and allocs
253b721 to
0edb5f1
Compare
Collaborator
CI test resultstest results on build#86940
|
Member
Author
|
/microbench |
Collaborator
|
Performance change detected in https://buildkite.com/redpanda/redpanda/builds/86950#019f4af0-35d2-41e5-8ac5-1b869c3d5e26: See https://redpandadata.atlassian.net/wiki/x/LQAqLg for docs |
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.
Remove task/scheduler-roundtrips and allocs from future-utils.
Backports Required
Release Notes