Skip to content

ExecutionInterceptorChain is reconstructed on every request despite the interceptor list being static #6848

@batrived

Description

@batrived

Summary

On every DynamoDB request, AwsExecutionContextBuilder.invokeInterceptorsAndCreateExecutionContext() invokes the full ExecutionInterceptorChain — including interceptors like DynamoDbResolveEndpointInterceptor and DynamoDbAuthSchemeInterceptor — even for work whose result is identical across all requests on the same client (endpoint resolution, auth scheme selection). Since the client configuration is immutable after build(), this work could be done once at construction time and reused.

Evidence

Using async-profiler on a JanusGraph server with a DynamoDB-heavy read workload (Query-dominated, ~thousands of DynamoDB calls/sec, SDK version 2.42.28):

Method Cumulative CPU
AwsExecutionContextBuilder.invokeInterceptorsAndCreateExecutionContext 6.44%
ExecutionInterceptorChain.modifyRequest 2.00%
ExecutionInterceptorChain$$Lambda_.accept 1.75%
ExecutionInterceptorChain.beforeExecution 1.19%
ExecutionInterceptorChain.modifyHttpRequestAndHttpContent 0.91%

The interceptor chain is executing on every request. For interceptors whose output depends only on static client configuration (endpoint, auth scheme, credentials provider type), this is redundant per-request work.

Specific interceptors doing static work per-request

Proposed fix

For interceptors whose modifyRequest output is a pure function of static client configuration, the SDK should either:

  1. Move that logic to a client construction-time step and cache the result, or
  2. Provide a mechanism for interceptors to declare themselves "static" so the framework can skip re-invoking them per request

This is consistent with the direction of PRs #6755 and #6820 (moving endpoint/auth-scheme resolution out of the interceptor framework into pipeline stages).

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions