Skip to content

perf(trace): avoid config allocation for retired kinds - #26026

Merged
mergify[bot] merged 4 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue25472-retired-kind-fastpath
Jul 22, 2026
Merged

mergify[bot] merged 4 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue25472-retired-kind-fastpath

Conversation

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #25472

What this PR does / why we need it:

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.

@matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label Jul 22, 2026
@VioletQwQ-0
VioletQwQ-0 marked this pull request as ready for review July 22, 2026 08:59
@VioletQwQ-0
VioletQwQ-0 requested a review from gouhongshen as a code owner July 22, 2026 08:59
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 gouhongshen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mergify mergify Bot added the queued label Jul 22, 2026
@mergify

mergify Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-22 14:04 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-07-22 15:15 UTC · at 713e2c52d2faf4638d3d579e00d1717eb6b44a75 · squash

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
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection] (documentation)
  • github-review-decision = APPROVED [🛡 GitHub branch protection] (documentation)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64

@mergify
mergify Bot merged commit 56f2d4d into matrixorigin:main Jul 22, 2026
23 of 24 checks passed
@mergify mergify Bot removed the queued label Jul 22, 2026
@VioletQwQ-0
VioletQwQ-0 deleted the codex/issue25472-retired-kind-fastpath branch July 23, 2026 07:53
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…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
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…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
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…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

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants