linera-protocol icon indicating copy to clipboard operation
linera-protocol copied to clipboard

Cache staged executions of the next block

Open ma2bd opened this issue 1 year ago • 1 comments

Motivation:

  • Most validators executing a certified block have already voted on the proposal.
  • Similarly, clients call handle_block_proposal locally at the beginning of block creation and call handle_certificate at the end.
  • On top of that, clients might stage the execution of a block even before calling handle_block_proposal locally (for a final verification).

Concretely, we could cache the value of ChainStateView just before it is rolled back in handle_block_proposal.

ma2bd avatar Dec 18 '23 11:12 ma2bd

I will add a single cache to WorkerState, next to the block cache, for now. (Both caches would work equally well if they were split up into one cache per chain, of course. This would prevent one chain evicting another chain's entries, but it would make it harder to control the total cache size.)

Minor issue: ValueCache requires V: Clone. ExecutionStateView isn't Clone, because ClonableView::clone_unchecked can fail. This is due to the ReentrantByteCollectionView, which tries locking an async RwLock. So I'm going to remove the V: Clone requirement from ValueCache, and move it to only the get method. (Needed because the actual LruCache is inside a mutex.) I'll add a new take method that removes the value. In the case of a block proposal, I'll just re-insert it. In the case of a confirmed block, we want to remove it anyway.

afck avatar Apr 03 '25 09:04 afck