Skip to content

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

Open
olavloite wants to merge 1 commit into
grpc:masterfrom
olavloite:unify-call-numbers
Open

olavloite wants to merge 1 commit into
grpc:masterfrom
olavloite:unify-call-numbers

Conversation

@olavloite

Copy link
Copy Markdown

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