osmosis icon indicating copy to clipboard operation
osmosis copied to clipboard

Make Export Less RAM Intensive (IAVL Changes)

Open czarcas7ic opened this issue 2 years ago • 3 comments

Background

It currently takes VMs with 64GB of RAM to export/import full state exports. Some basic IAVL improvements can be done to improve this performance.

Suggested Design

  • Key format change
    • Replace all native maps with BTree maps
  • We currently have atmoic writes at a per module scope, which is not efficient
    • We should lower the scope of atomic writes from the 100s of MBs to the 100s of KBs

Acceptance Criteria

  • Import/Export does not take extraordinary amounts of RAM to work

czarcas7ic avatar Oct 05 '22 17:10 czarcas7ic

Can I have some questions ?

  • What native maps should we replace ? Maybe maps like this ?
  • We should use https://github.com/tidwall/btree for BTree maps right ?

catShaark avatar Oct 10 '22 06:10 catShaark

We currently have atomic writes at a per module scope

This refers to cms Store's Write() right ? Can you explain this more ?

catShaark avatar Oct 11 '22 10:10 catShaark

I am going to have to have a separate conversation with Dev to get a better / more concrete understanding of the best way forward with this. This might have to happen later this week sadly

czarcas7ic avatar Oct 12 '22 01:10 czarcas7ic

seems like the non-atomic writes is explained here

catShaark avatar Oct 14 '22 09:10 catShaark

@czarcas7ic, do we have any update on this?

catShaark avatar Oct 28 '22 07:10 catShaark

I sadly do not have context on this, @ValarDragon would you be able to write something out in order to allow @catShaark to pick up this task?

czarcas7ic avatar Oct 31 '22 23:10 czarcas7ic

Key Format Changes

Basically make key formats we write to disk follow write_version | path_to_node

Replace all native maps with BTree maps

This is entirely unrelated

We currently have atmoic writes at a per module scope, which is not efficient

Basically just change the batch.set & batch.writeSync usage in IAVL, to write in many smaller batches. E.g. write every 1MB atomically, don't keep growing the batches. We already have tooling for detecting when we've completed the final write, the whole thing should not be atomic, it should just be possible to safely automatically rollback / wipe latest version.

ValarDragon avatar Nov 01 '22 04:11 ValarDragon

@catShaark I would love to work with you on smaller batch writing. Would you be interested in working together?

p0mvn avatar Nov 01 '22 04:11 p0mvn

yesss, just tell me what to do

catShaark avatar Nov 01 '22 05:11 catShaark

why not streaming of genesis? agree that batching would help but also streaming would be the correct solution

tac0turtle avatar Nov 01 '22 16:11 tac0turtle

Unneeded due to in-place testnet

ValarDragon avatar Feb 19 '24 17:02 ValarDragon