Skip to content

fix: reduce excess allocations (ENG-2036)#47

Draft
prestwich wants to merge 1 commit intoprestwich/eng-2126-exact-dual-fast-pathfrom
prestwich/eng-2036-reduce-allocations
Draft

fix: reduce excess allocations (ENG-2036)#47
prestwich wants to merge 1 commit intoprestwich/eng-2126-exact-dual-fast-pathfrom
prestwich/eng-2036-reduce-allocations

Conversation

@prestwich
Copy link
Copy Markdown
Member

Summary

  • drain_above: replace indexed .get(i).cloned() with .zip() to consume both iterators without cloning Vec<ColdReceipt> per block
  • ColdReceipt::new: destructure IndexedReceipt and into_iter() logs instead of .iter() + .clone()
  • write_block_to_tx: single-pass loop over transactions+receipts instead of collecting intermediate Vec<(tx_hash, sender)>
  • SqlColdBackend::new: match on &str directly instead of .to_owned()

Intentionally deferred (commented with ENG-2036)

  • Filter::clone() in produce_log_stream — requires cross-crate trait API change
  • Eager .into_owned() in traverse iterators — requires lifetime refactor of iterator structs
  • format!() SQL queries — dynamic filter clauses make this unavoidable; mitigated by sqlx prepared-statement cache

Test plan

  • cargo clippy (all-features + no-default-features) clean for all affected crates
  • cargo t passing for signet-storage, signet-cold, signet-cold-mdbx, signet-hot, signet-cold-sql

Blocked: depends on prestwich/eng-2126-exact-dual-fast-path

🤖 Generated with Claude Code

Eliminate unnecessary clones and intermediate collections:
- drain_above: zip iterators instead of indexed .get().cloned()
- ColdReceipt::new: destructure and into_iter() logs instead of cloning
- write_block_to_tx: single-pass loop instead of intermediate Vec
- SqlColdBackend::new: match on &str instead of .to_owned()

Add ENG-2036 comments for intentionally deferred items (Filter clone,
eager into_owned in traversals, format!() SQL queries).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@prestwich prestwich requested review from Evalir and Fraser999 April 7, 2026 18:26
@prestwich prestwich marked this pull request as draft April 8, 2026 15:30
@prestwich
Copy link
Copy Markdown
Member Author

depends on #46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant