Skip to content

perf(grpc-js): avoid building metadata map when parsing trailers - #3093

Merged
murgatroid99 merged 1 commit into
grpc:masterfrom
olavloite:skip-building-map-for-trailers
Sep 24, 2026
Merged

murgatroid99 merged 1 commit into
grpc:masterfrom
olavloite:skip-building-map-for-trailers

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

Read grpc-status and grpc-message directly from trailers using metadata.get() instead of calling metadata.getMap().

Calling metadata.getMap() on every completed RPC allocates a map object, iterates over all trailers, and clones binary buffers (such as grpc-status-details-bin) that are immediately thrown away. Reading the two needed headers directly avoids these allocations on the response hot path.

Read grpc-status and grpc-message directly from trailers using metadata.get()
instead of calling metadata.getMap().

Calling metadata.getMap() on every completed RPC allocates a map object,
iterates over all trailers, and clones binary buffers (such as
grpc-status-details-bin) that are immediately thrown away. Reading the two
needed headers directly avoids these allocations on the response hot path.
@murgatroid99
murgatroid99 merged commit 2ed54f8 into grpc:master Sep 24, 2026
9 of 10 checks passed
murgatroid99 pushed a commit that referenced this pull request Oct 7, 2026
Read grpc-status and grpc-message directly from trailers using metadata.get() instead of calling metadata.getMap().

Calling metadata.getMap() on every completed RPC allocates a map object, iterates over all trailers, and clones binary buffers (such as grpc-status-details-bin) that are immediately thrown away. Reading the two needed headers directly avoids these allocations on the response hot path.
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