Skip to content

Iterator time is exponential in number of Cache wrappings #10310

@yihuang

Description

@yihuang

Summary of Bug

evmos/ethermint#626
benchmark: evmos/ethermint#627
code of concern:

func (iter *cacheMergeIterator) skipUntilExistsOrInvalid() bool {

In ethermint we use a nested cache context stack to support the Snapshot and RevertToSnapshot APIs for EVM.
When EVM call Snapshot, we push a new cache context based on the top one, when RevertToSnapshot, we discard the cache contexts, after the execution, we commit all the cache contexts.
What we found is when the context stack is deep, it's extremely slow to create an iterator on it.

Version

v0.44.1

Steps to Reproduce


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions