Skip to content

Conversation

@arjan-bal
Copy link
Contributor

@arjan-bal arjan-bal commented May 26, 2025

This change uses a sync pool to cache itemNodes used by controlbuf and stores a method as a closure to avoid a heap allocation while creating frames for the controlbuf. This brings down allocs/op by ~18%.

go run benchmark/benchresult/main.go before after
streaming-networkMode_Local-bufConn_false-keepalive_false-benchTime_30s-trace_false-latency_0s-kbps_0-MTU_0-maxConcurrentCalls_60-reqS
ize_32384B-respSize_32384B-compressor_off-channelz_false-preloader_false-clientReadBufferSize_-1-clientWriteBufferSize_-1-serverReadBu
fferSize_-1-serverWriteBufferSize_-1-sleepBetweenRPCs_0s-connections_1-recvBufferPool_simple-sharedWriteBuffer_false
               Title       Before        After Percentage
            TotalOps      1089062      1092837     0.35%
             SendOps            0            0      NaN%
             RecvOps            0            0      NaN%
            Bytes/op    135783.55    135773.63    -0.01%
           Allocs/op        32.20        26.33   -18.63%
             ReqT/op 9404849015.47 9437448908.80     0.35%
            RespT/op 9404849015.47 9437448908.80     0.35%
            50th-Lat   1.646019ms   1.639128ms    -0.42%
            90th-Lat   2.280214ms   2.261793ms    -0.81%
            99th-Lat   2.692703ms   2.678714ms    -0.52%
             Avg-Lat   1.651539ms    1.64601ms    -0.33%
           GoVersion     go1.24.2     go1.24.2
         GrpcVersion   1.74.0-dev   1.74.0-dev

RELEASE NOTES:

  • transport: reduce heap allocations by pooling objects and avoiding method-to-closure conversions.
@arjan-bal arjan-bal added this to the 1.74 Release milestone May 26, 2025
@arjan-bal arjan-bal added Type: Performance Performance improvements (CPU, network, memory, etc) Area: Transport Includes HTTP/2 client/server and HTTP server handler transports and advanced transport features. labels May 26, 2025
@codecov
Copy link

codecov bot commented May 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.30%. Comparing base (32e57de) to head (9a521dc).
Report is 7 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8361      +/-   ##
==========================================
- Coverage   82.35%   82.30%   -0.05%     
==========================================
  Files         419      419              
  Lines       42034    42047      +13     
==========================================
- Hits        34615    34607       -8     
- Misses       5968     5980      +12     
- Partials     1451     1460       +9     
Files with missing lines Coverage Δ
internal/transport/controlbuf.go 89.79% <100.00%> (-0.90%) ⬇️
internal/transport/http2_server.go 90.82% <100.00%> (-0.27%) ⬇️

... and 19 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@dfawley dfawley assigned arjan-bal and unassigned dfawley May 27, 2025
@arjan-bal arjan-bal merged commit fb223f7 into grpc:master May 28, 2025
15 checks passed
@arjan-bal arjan-bal deleted the reduce-alloc-reset-ping branch May 28, 2025 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Transport Includes HTTP/2 client/server and HTTP server handler transports and advanced transport features. Type: Performance Performance improvements (CPU, network, memory, etc)

2 participants