Skip to content

Conversation

@DracoLi
Copy link
Contributor

@DracoLi DracoLi commented Oct 17, 2025

Why this should be merged

I noticed that during C-Chain block execution testing, each block accepted will trigger 3 block fetches (header, body, and receipts) for each accepted block. This happens when collecting unflattened logs in the acceptor queue (code).

Fetching block data should be fast but decompressing the data each time adds a lot of overhead. This overhead can be completely avoided with an cache because the block data should have been just written to the database.

A cache was not originally added to blockdb because the VMs all have caches for blocks already. But they can be bypassed due to oversight and having a cache at the db level ensures these kind of issues are avoided.

How this works

Added an lru cache with a size of 256 for data entries.
Cache is keyed by block height and is updated on Put and Get. This cache is used then checked on Get and Has.

How this was tested

Unit tests and reexecution benchmark

Need to be documented in RELEASES.md?

@joshua-kim joshua-kim moved this to Backlog 🧊 in avalanchego Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog 🧊

Development

Successfully merging this pull request may close these issues.

2 participants