Skip to content

MemIAVL

yihuang edited this page Jun 14, 2023 · 18 revisions

memiavl is a drop-in replacement for current iavl implementation, it's a huge performance boost for the node, it can be enabled by turn on the memiavl.enable config item in app.toml, it uses a standalone db directory data/memiavl.db, if you disable it later, the data/application.db will be used again by the default iavl, so it's ok to switch between them back and forth.

memiavl can only support pruned node, the default configuration(memiavl.snapshot-keep-recent=0) is equavalent to pruning=everything, to support historical grpc query service, you should enable versiondb together with it, if you need to support very old merkle proofs, don't use memiavl.

The default memiavl section in app.toml:

[memiavl]

# Enable defines if the memiavl should be enabled.
enable = false

# ZeroCopy defines if the memiavl should return slices pointing to mmap-ed buffers directly (zero-copy),
# the zero-copied slices must not be retained beyond current block's execution.
zero-copy = true

# AsyncCommitBuffer defines the size of asynchronous commit queue, this greatly improve block catching-up
# performance, -1 means synchronous commit.
async-commit-buffer = 0

# SnapshotKeepRecent defines what many old snapshots (excluding the latest one) to keep after new snapshots are taken.
snapshot-keep-recent = 0

# SnapshotInterval defines the block interval the memiavl snapshot is taken, default to 1000.
snapshot-interval = 1000

# CacheSize defines the size of the cache for each memiavl store, default to 1000.
cache-size = 1000

Use Cases

Semi-Archived Node

When versiondb is released, we recommend user to setup pruned iavl tree together with versiondb, to setup a semi-archived node, you can replace the pruned iavl tree with memiavl now.

State Sync Node

memiavl can do state-sync snapshot restoration much faster than current iavl, it's actually faster than chunk downloading speed, with memiavl, state-sync node can be bootstraped in around 10minutes depending on the internet speed, if you download snapshot from CDN and do local restoration, it'll be even faster.

Snapshot Providers

memiavl can do state-sync snapshot export much faster as well, on cronos mainnet, snapshots can be exported in minutes instead of days, so it's recommended to run snapshot provider nodes with memiavl, so the snapshots will be much more up-to-date.

Clone this wiki locally