Skip to content

chore(grpc-js): unify call numbers and avoid disabled trace allocations - #3084

Merged
murgatroid99 merged 1 commit into
grpc:masterfrom
olavloite:unify-call-numbers
Sep 16, 2026
Merged

murgatroid99 merged 1 commit into
grpc:masterfrom
olavloite:unify-call-numbers

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

Previously, each layer of an RPC (ResolvingCall, RetryingCall, LoadBalancingCall, and Http2SubchannelCall) allocated its own separate call number via getNextCallNumber(). This made correlating logs across layers difficult and consumed multiple IDs per logical RPC.

Additionally, dynamic trace arguments such as string concatenations, JSON.stringify(), and deadline formatting were evaluated eagerly at call sites even when tracing was disabled, adding unnecessary garbage collection pressure on the fast path.

This change:

  1. Passes the initial callNumber from ResolvingCall down through RetryingCall, LoadBalancingCall, and Http2SubchannelCall so that all layers of an attempt share the same call number. Subsequent retries and hedged attempts allocate a new call number per attempt.
  2. Short-circuits isTracerEnabled() when no tracers are active and guards dynamic trace argument evaluation behind traceEnabled checks so that disabled tracers incur zero string or formatting allocations.

Previously, each layer of an RPC (ResolvingCall, RetryingCall,
LoadBalancingCall, and Http2SubchannelCall) allocated its own separate
call number via getNextCallNumber(). This made correlating logs across
layers difficult and consumed multiple IDs per logical RPC.

Additionally, dynamic trace arguments such as string concatenations,
JSON.stringify(), and deadline formatting were evaluated eagerly at call
sites even when tracing was disabled, adding unnecessary garbage
collection pressure on the fast path.

This change:
1. Passes the initial callNumber from ResolvingCall down through
   RetryingCall, LoadBalancingCall, and Http2SubchannelCall so that all
   layers of an attempt share the same call number. Subsequent retries
   and hedged attempts allocate a new call number per attempt.
2. Short-circuits isTracerEnabled() when no tracers are active and guards
   dynamic trace argument evaluation behind traceEnabled checks so that
   disabled tracers incur zero string or formatting allocations.
@murgatroid99
murgatroid99 merged commit f5f2ec0 into grpc:master Sep 16, 2026
4 of 5 checks passed
@murgatroid99

Copy link
Copy Markdown
Member

This is out in version 1.14.5.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants