reth icon indicating copy to clipboard operation
reth copied to clipboard

Tune performance of fetch pending hashes

Open Elvis339 opened this issue 11 months ago • 8 comments
trafficstars

Describe the feature

This issue builds on Profile tx fetching to improve transaction fetching performance.

Optimizations Applied

  • Removed nested call stacks in hash computations
  • Eliminated function passing through multiple levels
  • Converted deferred/batch cleanups to eager processing
  • Added strategic early returns
  • Inlining
  • Streamlined LRU cache access patterns

These changes resulted in ~51% performance improvement in transaction fetching operations.

Additional Consideration: LRU Usage

Currently, some fields like seen_hashes are using an LRU cache, but this might not be optimal.

Why LRU might not be ideal:

  1. Do we actually need ordering? Seems like main purpose is deduplication?
  2. LRU operations have overhead from maintaining order
  3. Cache eviction order might not align with transaction processing patterns

Would love feedback on whether ordering is actually important, as moving to a simpler data structure could yield sweet performance juice.

Additional context

Flamegraphs

Not Optimized

Image

Optimized

Image

Benchmark

Not Optimized

Image

Optimized

Image

Elvis339 avatar Dec 09 '24 08:12 Elvis339