Skip to content

perf(chainlib): zero-copy passthrough in checkUTXOResponseAndFixReply…#2269

Merged
nimrod-teich merged 1 commit intomainfrom
perf/utxo-response-bytes-passthrough
Apr 16, 2026
Merged

perf(chainlib): zero-copy passthrough in checkUTXOResponseAndFixReply…#2269
nimrod-teich merged 1 commit intomainfrom
perf/utxo-response-bytes-passthrough

Conversation

@NadavLevi
Copy link
Copy Markdown
Collaborator

… for non-UTXO chains

The function unconditionally did string(replyData) on entry, which allocated a full copy of every upstream reply body — even for non-UTXO chains that then returned immediately without using it. A live pprof capture on the eth router attributed ~4.5 GB of inuse memory over a 12-minute window to this single allocation.

Return []byte and only reformat on the UTXO path; non-UTXO chains (ETH, Cosmos, tendermint, etc.) now pass through the original slice with no copy. Test coverage adds a pointer-identity assertion so any future regression that reintroduces an eager copy fails loudly.

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...

  • read the contribution guide
  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the main branch
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers 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...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 31.25000% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
protocol/chainlib/common.go 45.45% 6 Missing ⚠️
protocol/chainlib/jsonRPC.go 0.00% 5 Missing ⚠️
Flag Coverage Δ
consensus 8.98% <ø> (ø)
protocol 35.22% <31.25%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
protocol/chainlib/jsonRPC.go 44.56% <0.00%> (-0.29%) ⬇️
protocol/chainlib/common.go 50.25% <45.45%> (-2.60%) ⬇️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 14, 2026

Test Results

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
7 files   ±0   0 ❌ ±0 

Results for commit 666c1a4. ± Comparison against base commit 2d92617.

♻️ This comment has been updated with latest results.

@NadavLevi NadavLevi requested a review from avitenzer April 15, 2026 06:37
Comment thread protocol/chainlib/jsonRPC.go
Comment thread protocol/chainlib/common.go
… for non-UTXO chains

The function unconditionally did `string(replyData)` on entry, which allocated a
full copy of every upstream reply body — even for non-UTXO chains that then
returned immediately without using it. A live pprof capture on the eth router
attributed ~4.5 GB of inuse memory over a 12-minute window to this single
allocation.

Return []byte and only reformat on the UTXO path; non-UTXO chains (ETH, Cosmos,
tendermint, etc.) now pass through the original slice with no copy. Test
coverage adds a pointer-identity assertion so any future regression that
reintroduces an eager copy fails loudly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@NadavLevi NadavLevi force-pushed the perf/utxo-response-bytes-passthrough branch from 4d97402 to 666c1a4 Compare April 15, 2026 16:58
@NadavLevi NadavLevi requested a review from avitenzer April 15, 2026 16:58
@nimrod-teich nimrod-teich merged commit bd58479 into main Apr 16, 2026
30 checks passed
@nimrod-teich nimrod-teich deleted the perf/utxo-response-bytes-passthrough branch April 16, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants