Skip to content

[pdata] Use pool-aware constructors in gRPC service handlers#14763

Merged
mx-psi merged 3 commits into
open-telemetry:mainfrom
kevinburkesegment:use-new-new
Apr 22, 2026
Merged

[pdata] Use pool-aware constructors in gRPC service handlers#14763
mx-psi merged 3 commits into
open-telemetry:mainfrom
kevinburkesegment:use-new-new

Conversation

@kevinburkesegment

Copy link
Copy Markdown
Contributor

Description

The gRPC service handlers for all four signal types allocate the top-level ExportXxxServiceRequest with bare new(), bypassing the sync.Pool when pdata.useProtoPooling is enabled. This means objects returned to the pool via Delete are never retrieved, so the pool accumulates unreused objects.

Replace new() with the pool-aware New*() constructors so the top-level request struct participates in the pool lifecycle.

benchstat (20 runs, pdata.useProtoPooling=true, 10k logs/request):

                             │   old (new())   │  new (New*())    │
                             │     sec/op      │  sec/op  vs base │
GRPCLogsSequentialPooling-12     3.858m ± 2%   3.811m ± 1%  ~ (p=0.165 n=20)
                             │      B/op       │   B/op   vs base │
GRPCLogsSequentialPooling-12    3.551Mi ± 2%  3.523Mi ± 1%  ~ (p=0.445 n=20)
                             │   allocs/op     │ allocs/op vs base│
GRPCLogsSequentialPooling-12     75.46k ± 0%   75.46k ± 0%  ~ (p=0.867 n=20)

No measurable perf difference (1 alloc out of 75k), but this is a correctness fix for the pool lifecycle.

Assisted-by: Claude Opus 4.6

Link to tracking issue

Fixes #

Testing

Documentation

@linux-foundation-easycla

linux-foundation-easycla Bot commented Mar 12, 2026

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: kevinburkesegment / name: Kevin Burke (0c24389, d7eb642)
  • ✅ login: mx-psi / name: Pablo Baeyens (72bdc5d)

@kevinburkesegment

Copy link
Copy Markdown
Contributor Author

/easycla

@dmathieu

Copy link
Copy Markdown
Member

This should have a changelog entry.

@codecov

codecov Bot commented Mar 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.35%. Comparing base (5674bf2) to head (72bdc5d).
⚠️ Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
pdata/internal/otelgrpc/profiles_service.go 0.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (75.00%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14763      +/-   ##
==========================================
- Coverage   91.30%   90.35%   -0.95%     
==========================================
  Files         699      700       +1     
  Lines       44940    53801    +8861     
==========================================
+ Hits        41034    48614    +7580     
- Misses       2761     4042    +1281     
  Partials     1145     1145              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kevinburkesegment
kevinburkesegment force-pushed the use-new-new branch 2 times, most recently from c6192c5 to 3145851 Compare March 16, 2026 17:02
@kevinburkesegment

Copy link
Copy Markdown
Contributor Author

Please take another look

@github-actions

Copy link
Copy Markdown
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@kevinburkesegment

Copy link
Copy Markdown
Contributor Author

I think this change still makes sense to merge

@dmathieu dmathieu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for the staleness here. This definitely makes sense.

@dmathieu dmathieu added ready-to-merge Code review completed; ready to merge by maintainers and removed Stale labels Mar 31, 2026
Comment thread .chloggen/pdata-grpc-pool-aware-constructors.yaml Outdated
The gRPC service handlers for all four signal types allocate the
top-level ExportXxxServiceRequest with bare new(), bypassing the
sync.Pool when pdata.useProtoPooling is enabled. This means objects
returned to the pool via Delete are never retrieved, so the pool
accumulates unreused objects.

Replace new() with the pool-aware New*() constructors so the
top-level request struct participates in the pool lifecycle.

benchstat (20 runs, pdata.useProtoPooling=true, 10k logs/request):

                             │   old (new())   │  new (New*())    │
                             │     sec/op      │  sec/op  vs base │
GRPCLogsSequentialPooling-12     3.858m ± 2%   3.811m ± 1%  ~ (p=0.165 n=20)
                             │      B/op       │   B/op   vs base │
GRPCLogsSequentialPooling-12    3.551Mi ± 2%  3.523Mi ± 1%  ~ (p=0.445 n=20)
                             │   allocs/op     │ allocs/op vs base│
GRPCLogsSequentialPooling-12     75.46k ± 0%   75.46k ± 0%  ~ (p=0.867 n=20)

No measurable perf difference (1 alloc out of 75k), but this is a
correctness fix for the pool lifecycle.

Assisted-by: Claude Opus 4.6
@kevinburkesegment

Copy link
Copy Markdown
Contributor Author

@dmathieu rebased against current main and fixed the component

Comment thread .chloggen/pdata-grpc-pool-aware-constructors.yaml Outdated
@mx-psi
mx-psi enabled auto-merge April 22, 2026 09:24
@mx-psi
mx-psi added this pull request to the merge queue Apr 22, 2026
Merged via the queue into open-telemetry:main with commit a54d19e Apr 22, 2026
64 of 65 checks passed
@otelbot

otelbot Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution @kevinburkesegment! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

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

Labels

ready-to-merge Code review completed; ready to merge by maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants