Skip to content

perf(transcode): remove per-request route allocations on the hot path #41

Description

@polaz

Two avoidable per-request allocations on the proxied-request hot path:

  1. RouteEntry is deep-cloned per request (the handler closure captures it by value; axum clones the closure per request, deep-cloning its String fields). Wrap in Arc<RouteEntry> so the per-request clone is a single refcount bump.
  2. grpc_path is re-parsed into PathAndQuery on every request in both the unary and streaming handlers. Parse it once at route-build time and store the PathAndQuery (its clone is a cheap Bytes refcount bump). This also moves invalid-path detection to startup instead of a per-request 500 branch.

Both are zero-correctness-risk micro-optimizations on the hottest path; SIMD/wildcopy are not applicable (no hot scalar byte loops; byte work lives in serde_json / prost / hyper).

Estimate: 2h

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions