Skip to content

fix: minor performance optimization#2178

Merged
nimrod-teich merged 2 commits into
mainfrom
memory-optimization-fixes
Jan 11, 2026
Merged

fix: minor performance optimization#2178
nimrod-teich merged 2 commits into
mainfrom
memory-optimization-fixes

Conversation

@NadavLevi

Copy link
Copy Markdown
Contributor

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

nimrod-teich
nimrod-teich previously approved these changes Jan 11, 2026
@github-actions

Copy link
Copy Markdown

Test Results

    7 files  ±0    129 suites  +1   33m 11s ⏱️ - 1m 10s
3 190 tests ±0  3 189 ✅ ±0  1 💤 ±0  0 ❌ ±0 
3 273 runs  ±0  3 272 ✅ ±0  1 💤 ±0  0 ❌ ±0 

Results for commit 4578781. ± Comparison against base commit 254b8d4.

…mory allocation

The testing_helpers.go file was creating a RelayRetriesManager with a ~200MB
ristretto cache at package init time, even in production builds.

Changes:
- Renamed protocol/relaycore/testing_helpers.go to testing_helpers_test.go
  (only compiled during tests for internal package tests)
- Created protocol/relaycoretest/ package for external test packages to import
- Updated test files in rpcconsumer and rpcsmartrouter to use relaycoretest

This eliminates ~200MB of unnecessary memory allocation in production builds.
Eliminated duplicate GetReqHeaders() calls in HTTP handlers:
- jsonRPC.go: Reuse metadataValues in AddMetricForHttp()
- tendermintRPC.go: Same optimization (2 locations)
- rest.go: Same optimization (2 locations)

Each GetReqHeaders() call creates a new map allocation. At 1000 req/s,
eliminating the duplicate call saves ~2000 map allocations per second,
reducing header-related memory pressure by ~50%.
@nimrod-teich nimrod-teich merged commit a42bcff into main Jan 11, 2026
16 checks passed
@nimrod-teich nimrod-teich deleted the memory-optimization-fixes branch January 11, 2026 14:02
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.

2 participants