perf(chainlib): send response bodies as bytes via fiber.Ctx.Send#2270
Merged
nimrod-teich merged 1 commit intomainfrom Apr 16, 2026
Merged
perf(chainlib): send response bodies as bytes via fiber.Ctx.Send#2270nimrod-teich merged 1 commit intomainfrom
nimrod-teich merged 1 commit intomainfrom
Conversation
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
avitenzer
reviewed
Apr 15, 2026
fc41b0f to
7cb5445
Compare
avitenzer
previously approved these changes
Apr 16, 2026
addHeadersAndSendString called fiber.Ctx.SendString, which copies the string into fasthttp's response bytebufferpool. All callers in the relay path already hold the body as []byte (reply.Data) or as JSON marshal output (also []byte) and were round-tripping through string() at the call site. That string() conversion is a full per-request copy on top of the unavoidable copy into fasthttp's buffer — visible in pprof as 96 GB inuse under bytebufferpool.(*ByteBuffer).WriteString on the eth router. Rename to addHeadersAndSendBytes, take []byte, and use fiber.Ctx.Send. Update every caller (jsonRPC, tendermintRPC, rest) to drop the string() round-trip on success paths where reply.Data is already []byte; error paths keep []byte(s) on the small error strings since those aren't on the hot path. Add focused tests covering body + metadata headers, the empty-body case, and a binary payload round-trip to guard against a regression that reintroduces the string() conversion. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
7cb5445 to
9034038
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
addHeadersAndSendString called fiber.Ctx.SendString, which copies the string into fasthttp's response bytebufferpool. All callers in the relay path already hold the body as []byte (reply.Data) or as JSON marshal output (also []byte) and were round-tripping through string() at the call site. That string() conversion is a full per-request copy on top of the unavoidable copy into fasthttp's buffer — visible in pprof as 96 GB inuse under bytebufferpool.(*ByteBuffer).WriteString on the eth router.
Rename to addHeadersAndSendBytes, take []byte, and use fiber.Ctx.Send. Update every caller (jsonRPC, tendermintRPC, rest) to drop the string() round-trip on success paths where reply.Data is already []byte; error paths keep []byte(s) on the small error strings since those aren't on the hot path. Add focused tests covering body + metadata headers, the empty-body case, and a binary payload round-trip to guard against a regression that reintroduces the string() conversion.
Description
Closes: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!in the type prefix if API or client breaking changemainbranchReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...