You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf(chainlib): send response bodies as bytes via fiber.Ctx.Send (#2270)
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>
0 commit comments