Repository navigation
perf(trace): skip span construction when level is filtered out - #26
Merged
Merged
Conversation
Benchmark follow-up to BENCHMARK_REPORT.md section 3: TraceLayer built three Strings plus a version format! per request even when no subscriber was listening, costing ~51% of throughput under load. DefaultMakeSpan::make_span now checks per-level callsite interest via tracing::enabled! and returns Span::none() when the configured level is filtered out. record() on a disabled span remains a no-op, so handler behavior is unchanged; spans still appear exactly as before whenever the level is enabled. Re-benchmarked (wrk 4t/256c, RUST_LOG=off, laptop loopback): middleware-mode throughput improved from ~156k to ~218-254k req/s (median across interleaved rounds), overhead vs bare route dropped from -50.6% to about -16%, and p99 fell from 5.48ms to 2.62ms. Restores a clear lead over actix-web (189k) and axum (124k) in the with-middleware configuration. Full data in BENCHMARK_REPORT.md §8. Co-Authored-By: Claude <noreply@anthropic.com>
1 task done
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.
Summary
Follow-up to the benchmark report (
BENCHMARK_REPORT.md, committed on main via #25):TraceLayerbuilt threeStrings plus aformat!per request even with no tracing subscriber installed — measured at −50.6% throughput in middleware-heavy deployments.DefaultMakeSpan::make_spannow checks per-level callsite interest viatracing::enabled!and returnsSpan::none()when the configured level is filtered out. Spans behave exactly as before whenever the level is enabled.Benchmark (wrk 4t/256c, RUST_LOG=off, laptop loopback)
With this gate, arvik's middleware-mode throughput beats actix-web (189k) and axum (124k) — full data in
BENCHMARK_REPORT.md §8.Verification
cargo test -p arvik-middleware— 26/26 passcargo clippy --workspace --all-features -- -D warnings— cleancargo fmt --all -- --check— cleanCloses the optimization target identified in the benchmark analysis.