Skip to content

Change the IAVL iterators to not be channel based #10335

Closed
@ValarDragon

Description

Summary

cref tendermint/tm-db#188.

The IAVL iterator creates a channel, and spawns multiple processes in order to work at the moment. This is inefficient, as we get lots of time spent in checking mutex locks, inter-channel message passing, and extra processes lying around within the state machine. (It will also be a barrier to parallelism in the future)

This all only makes sense if we're designing for the use case of multiple threads reading from the same iterator, which doesn't make sense. A good parallelism design would aim to make multiple iterators over non-overlapping parts of state. Even if we were designing for this, only the mutex locks make sense, the separately spawned iterator channels do not.

I recommend that we change this to remove the need for the extraneous channels entirely, and just have a struct maintain the context. This is much simpler, and faster to execute. I think we should also remove the locks, but thats secondary to removing the channels.

Problem Definition

IAVL store iterators are resource intensive.

Proposal

  • Remove the channels entirely within the iterators, and just use structs there.
  • Remove the locks in the iterator as well. (These locks only belong if multiple processes need to read from the same IAVL iterator, which does not make sense to me)

For Admin Use

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

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions