Skip to content

perf(gRPC): reduce object allocations on the gRPC client side for unified cancel scenarios#1950

Merged
DMwangnima merged 1 commit intocloudwego:mainfrom
DMwangnima:perf/grpc-object-alloc
Apr 20, 2026
Merged

perf(gRPC): reduce object allocations on the gRPC client side for unified cancel scenarios#1950
DMwangnima merged 1 commit intocloudwego:mainfrom
DMwangnima:perf/grpc-object-alloc

Conversation

@DMwangnima
Copy link
Copy Markdown
Contributor

@DMwangnima DMwangnima commented Apr 16, 2026

What type of PR is this?

perf

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:

  • Split closeStream into casStreamDone and doCloseStream so that Tick can skip already-closed streams before constructing status/error objects.
  • Introduce contextStatusAndErr returning reused singleton status and error for context.Canceled / context.DeadlineExceeded to avoid per-stream allocation.
  • Guard shared status via Stream.reuseStatus flag and lazy deep copy in Stream.Status().
  • Remove unused eosReceived parameter from client-side closeStream.
  • Add reuseStatus defense tests and closeStreamTask
  • Tick benchmarks.

zh(optional):

(Optional) Which issue(s) this PR fixes:

(optional) The PR that updates user documentation:

@DMwangnima DMwangnima requested review from a team as code owners April 16, 2026 12:43
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 82.05128% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.63%. Comparing base (bfa27f3) to head (779b183).
⚠️ Report is 45 commits behind head on main.

Files with missing lines Patch % Lines
pkg/remote/trans/nphttp2/grpc/http2_client.go 70.83% 6 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1950      +/-   ##
==========================================
+ Coverage   61.37%   62.63%   +1.25%     
==========================================
  Files         388      393       +5     
  Lines       35063    30106    -4957     
==========================================
- Hits        21521    18857    -2664     
+ Misses      12247     9952    -2295     
- Partials     1295     1297       +2     
Flag Coverage Δ
integration 51.63% <56.41%> (+1.13%) ⬆️
unit 53.04% <79.48%> (+1.40%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

…fied cancel scenarios

Split closeStream into casStreamDone and doCloseStream so that Tick can
skip already-closed streams before constructing status/error objects.
Introduce contextStatusAndErr returning reused singleton status and error
for context.Canceled / context.DeadlineExceeded to avoid per-stream allocation.
Guard shared status via Stream.reuseStatus flag and lazy deep copy in Stream.Status().
Remove unused eosReceived parameter from client-side closeStream.
Add reuseStatus defense tests and closeStreamTask Tick benchmarks.
@DMwangnima DMwangnima force-pushed the perf/grpc-object-alloc branch from 427953f to 779b183 Compare April 19, 2026 13:44
Comment thread pkg/remote/trans/nphttp2/grpc/transport.go
@DMwangnima DMwangnima merged commit 73d007a into cloudwego:main Apr 20, 2026
26 of 27 checks passed
@DMwangnima DMwangnima deleted the perf/grpc-object-alloc branch April 20, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants