Skip to content

fix: batch memory optimisation#2132

Merged
nimrod-teich merged 13 commits into
mainfrom
sendbatch_optimisation
Dec 8, 2025
Merged

fix: batch memory optimisation#2132
nimrod-teich merged 13 commits into
mainfrom
sendbatch_optimisation

Conversation

@avitenzer

@avitenzer avitenzer commented Dec 4, 2025

Copy link
Copy Markdown
Collaborator

…g entire array

  • Replace batch array decode with streaming token-by-token parsing
  • Reduces memory usage for large batch responses (e.g., eth_getBlockByNumber with full txs)
  • Validates JSON array structure explicitly with proper error messages
  • Adds context cancellation support during batch processing
  • Maintains synchronous behavior for consistency with sendHTTP
  • bypass heavy bucket when we process a batch

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

Note

Streams batch JSON decoding to reduce memory and adds batch (ampersand-joined) methods bypass in resource limiter with tests.

  • RPC Client (protocol/chainlib/chainproxy/rpcclient/http.go)
    • Replace full-array decode in sendBatchHTTP with streaming json.Decoder parsing.
    • Explicitly validate [/] tokens and support context cancellation while streaming responses.
  • Provider Resource Limiter (protocol/rpcprovider)
    • Update selectBucket to treat methods containing & as batch and route to BucketNormal (before CU/prefix checks).
    • Add unit tests covering ampersand batch classification and interaction with CU and prefixes.

Written by Cursor Bugbot for commit d544c05. This will update automatically on new commits. Configure here.

…g entire array

- Replace batch array decode with streaming token-by-token parsing
- Reduces memory usage for large batch responses (e.g., eth_getBlockByNumber with full txs)
- Validates JSON array structure explicitly with proper error messages
- Adds context cancellation support during batch processing
- Maintains synchronous behavior for consistency with sendHTTP
- Updated the selectBucket method to ensure that methods containing ampersands are classified into the normal bucket, bypassing compute unit checks.
- Added new test cases to validate the behavior of batch methods with ampersands, ensuring correct bucket selection under various scenarios.
- Improved comments in the code for better clarity on the prioritization logic in resource classification.
@github-actions

github-actions Bot commented Dec 4, 2025

Copy link
Copy Markdown

Test Results

    7 files  +  2    130 suites  +3   30m 43s ⏱️ + 11m 11s
3 102 tests +195  3 101 ✅ +203  1 💤 ±0  0 ❌  - 2 
3 182 runs  +195  3 181 ✅ +203  1 💤 ±0  0 ❌  - 2 

Results for commit 9d48aa9. ± Comparison against base commit 248c649.

♻️ This comment has been updated with latest results.

AnnaR-prog
AnnaR-prog previously approved these changes Dec 4, 2025
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Dec 8, 2025
@nimrod-teich nimrod-teich merged commit df3f4ac into main Dec 8, 2025
30 checks passed
@nimrod-teich nimrod-teich deleted the sendbatch_optimisation branch December 8, 2025 11:50
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