Repository navigation
perf(trace): avoid config allocation for retired kinds - #26026
mergify[bot] merged 4 commits into
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed exact head 9d4f861. No blocking issues found.
The single-KindOption fast path is semantically equivalent for retired kinds, while custom and ordered/multiple options retain the general path. Nil-context behavior and trace-context propagation remain unchanged.
Verified locally: target and dependent package tests, 100x focused race tests, go vet, formatting/diff checks, and allocation benchmarks (16 B/1 alloc fast path vs 160 B/2 alloc general path).
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
No findings. The exact KindOption fast path preserves prior behavior; custom and ordered options retain the general path. Focused trace tests, vet, and allocation benchmarks passed.
Merge Queue Status
This pull request spent 1 hour 11 minutes 24 seconds in the queue, including 1 hour 4 minutes 18 seconds running CI. Required conditions to merge
|
…26026) `NonRecordingTracer.Start` still builds a `SpanConfig` and applies options for controlled span kinds whose recording pipelines have been retired. In the common production shape, the caller passes exactly one concrete `KindOption`, so that work is unnecessary. This PR adds a narrow fast path for exactly one retired `KindOption`. It returns the normalized context and `NoopSpan` before constructing `SpanConfig`. The general path remains unchanged for: - zero options and non-retired kinds; - custom `SpanStartOption` implementations; - multiple options, including order-sensitive kind overrides; - the alternate disabled-observability `NoopTracer` provider. Regression coverage includes all four retired controlled kinds, nil-context normalization, custom-option side effects, and both multi-option orderings. Validation on current `main`: - `go test -count=1 ./pkg/util/trace ./pkg/util/trace/impl/motrace` - focused `go test -race` and `-count=100` tests - `go vet ./pkg/util/trace` - compile-only checks for `pkg/frontend`, `pkg/sql/compile`, `pkg/tnservice`, `pkg/fileservice`, and `pkg/common/morpc` - five benchmark runs: fast path `18.19-23.25 ns/op, 16 B/op, 1 alloc/op`; general-path reference `51.49-59.10 ns/op, 160 B/op, 2 alloc/op` Independent fresh-data A/B/A on mo-55 measured: - TPS: `+0.45%` - CPU/query: `-0.56%` - alloc bytes/query: `-3.86%` - malloc objects/query: `-2.35%` - GC cycles/query: `-3.98%` The allocation profile removed approximately `4.018 GB / 60s` and `29.25M objects / 60s` attributed to `NonRecordingTracer.Start`, without an equivalent hotspot migration. The throughput result is intentionally treated as neutral; the demonstrated benefit is reduced allocation churn. The remote performance run used base `3046f14d94b3f1a25839eeeb65729b64f85ac647`; the affected implementation and surrounding provider/config files were unchanged between that base and this PR's current-main base. Approved by: @XuPeng-SH, @gouhongshen
…26026) `NonRecordingTracer.Start` still builds a `SpanConfig` and applies options for controlled span kinds whose recording pipelines have been retired. In the common production shape, the caller passes exactly one concrete `KindOption`, so that work is unnecessary. This PR adds a narrow fast path for exactly one retired `KindOption`. It returns the normalized context and `NoopSpan` before constructing `SpanConfig`. The general path remains unchanged for: - zero options and non-retired kinds; - custom `SpanStartOption` implementations; - multiple options, including order-sensitive kind overrides; - the alternate disabled-observability `NoopTracer` provider. Regression coverage includes all four retired controlled kinds, nil-context normalization, custom-option side effects, and both multi-option orderings. Validation on current `main`: - `go test -count=1 ./pkg/util/trace ./pkg/util/trace/impl/motrace` - focused `go test -race` and `-count=100` tests - `go vet ./pkg/util/trace` - compile-only checks for `pkg/frontend`, `pkg/sql/compile`, `pkg/tnservice`, `pkg/fileservice`, and `pkg/common/morpc` - five benchmark runs: fast path `18.19-23.25 ns/op, 16 B/op, 1 alloc/op`; general-path reference `51.49-59.10 ns/op, 160 B/op, 2 alloc/op` Independent fresh-data A/B/A on mo-55 measured: - TPS: `+0.45%` - CPU/query: `-0.56%` - alloc bytes/query: `-3.86%` - malloc objects/query: `-2.35%` - GC cycles/query: `-3.98%` The allocation profile removed approximately `4.018 GB / 60s` and `29.25M objects / 60s` attributed to `NonRecordingTracer.Start`, without an equivalent hotspot migration. The throughput result is intentionally treated as neutral; the demonstrated benefit is reduced allocation churn. The remote performance run used base `3046f14d94b3f1a25839eeeb65729b64f85ac647`; the affected implementation and surrounding provider/config files were unchanged between that base and this PR's current-main base. Approved by: @XuPeng-SH, @gouhongshen
…26026) `NonRecordingTracer.Start` still builds a `SpanConfig` and applies options for controlled span kinds whose recording pipelines have been retired. In the common production shape, the caller passes exactly one concrete `KindOption`, so that work is unnecessary. This PR adds a narrow fast path for exactly one retired `KindOption`. It returns the normalized context and `NoopSpan` before constructing `SpanConfig`. The general path remains unchanged for: - zero options and non-retired kinds; - custom `SpanStartOption` implementations; - multiple options, including order-sensitive kind overrides; - the alternate disabled-observability `NoopTracer` provider. Regression coverage includes all four retired controlled kinds, nil-context normalization, custom-option side effects, and both multi-option orderings. Validation on current `main`: - `go test -count=1 ./pkg/util/trace ./pkg/util/trace/impl/motrace` - focused `go test -race` and `-count=100` tests - `go vet ./pkg/util/trace` - compile-only checks for `pkg/frontend`, `pkg/sql/compile`, `pkg/tnservice`, `pkg/fileservice`, and `pkg/common/morpc` - five benchmark runs: fast path `18.19-23.25 ns/op, 16 B/op, 1 alloc/op`; general-path reference `51.49-59.10 ns/op, 160 B/op, 2 alloc/op` Independent fresh-data A/B/A on mo-55 measured: - TPS: `+0.45%` - CPU/query: `-0.56%` - alloc bytes/query: `-3.86%` - malloc objects/query: `-2.35%` - GC cycles/query: `-3.98%` The allocation profile removed approximately `4.018 GB / 60s` and `29.25M objects / 60s` attributed to `NonRecordingTracer.Start`, without an equivalent hotspot migration. The throughput result is intentionally treated as neutral; the demonstrated benefit is reduced allocation churn. The remote performance run used base `3046f14d94b3f1a25839eeeb65729b64f85ac647`; the affected implementation and surrounding provider/config files were unchanged between that base and this PR's current-main base. Approved by: @XuPeng-SH, @gouhongshen
What type of PR is this?
Which issue(s) this PR fixes:
issue #25472
What this PR does / why we need it:
NonRecordingTracer.Startstill builds aSpanConfigand applies options for controlled span kinds whose recording pipelines have been retired. In the common production shape, the caller passes exactly one concreteKindOption, so that work is unnecessary.This PR adds a narrow fast path for exactly one retired
KindOption. It returns the normalized context andNoopSpanbefore constructingSpanConfig.The general path remains unchanged for:
SpanStartOptionimplementations;NoopTracerprovider.Regression coverage includes all four retired controlled kinds, nil-context normalization, custom-option side effects, and both multi-option orderings.
Validation on current
main:go test -count=1 ./pkg/util/trace ./pkg/util/trace/impl/motracego test -raceand-count=100testsgo vet ./pkg/util/tracepkg/frontend,pkg/sql/compile,pkg/tnservice,pkg/fileservice, andpkg/common/morpc18.19-23.25 ns/op, 16 B/op, 1 alloc/op; general-path reference51.49-59.10 ns/op, 160 B/op, 2 alloc/opIndependent fresh-data A/B/A on mo-55 measured:
+0.45%-0.56%-3.86%-2.35%-3.98%The allocation profile removed approximately
4.018 GB / 60sand29.25M objects / 60sattributed toNonRecordingTracer.Start, without an equivalent hotspot migration. The throughput result is intentionally treated as neutral; the demonstrated benefit is reduced allocation churn.The remote performance run used base
3046f14d94b3f1a25839eeeb65729b64f85ac647; the affected implementation and surrounding provider/config files were unchanged between that base and this PR's current-main base.