New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transition from RocksDB to Rust based database implementation #13340
Conversation
Why would this be a worthwhile change? Is there a quantifiable performance improvement? |
Same question as @psteckler — What is the motivation to move away from a stable battle-tested kvstore here? I’m not a databases expert, but I know that it is very tricky to thoroughly test these sorts of systems and the Lindy effect of a well-known open source project seems hard to give up to me. |
We can expand the documentation and clarify how we tested this implementation. We believe the quality is comparable, possibly slightly better, because it is less complex than RocksDB. However, from the Lindy effect perspective, we can't compete with RocksDB. The key benefit of this PR is that it allows us to refine the ledger's implementation as we move forward with replacing the ledger's upper layers with the Rust version. At the moment, we need to ensure full compatibility with the ledger's existing OCaml implementation, which limits our ability to make substantial improvements. We do have the option to bypass this PR and draft a new one for a complete ledger replacement (including the transaction application logic). However, that would be a much more complex change to review, and it would also significantly increase the time required for completion. |
One important detail that I think is not clear is that while this PR (in its current form) replaces RocksDB, that is not required, and the Mina node can keep working as usual with a RocksDB storage. What is important is to have an easy way to switch between different implementations (probably through dune's virtual libraries feature) that provide the same interface as the current RocksDB backend. So the default will still be RocksDB, with the option to switch the backend to something else over which we have more control so that the (Rust) Ledger implementation can take advantage of it, as Juraj mentioned above. |
@jurajselep @sebastiencs What's the status of this PR? Nothing has happened for 9 months. Can we close it? |
Hi @rbonichon, at the moment we are not planning on supporting this database, so yes, lets close this issue. |
Explain your changes:
This PR removes the
RocksDB
dependency, replacing it with a Rust implementation.The new database follows the same API than the previous
rocksdb
package, making it a drop-in replacement.Compression is used on both keys and values, using zstd algorithm.
Encoding and decoding of data remains the same with binprot.
crc32
is used to validate data integrity.Explain how you tested your changes:
This new database implementation has been tested by running the Mina node, including this implementation, on berkeleynet for a few days now.
Implementation details
The database is a single append-only file, where each entry (key-value) are preceded by a header.
Each entry in the Database has the following structure:
Where:
HDR
: A 17 bytes headerKEY_LENGTH
: Length of the key, stored in 4 bytes.VALUE_LENGTH
: Length of the value, stored in 8 bytes.BITFLAGS
: A 1 byte bitflags including:key_is_compressed
: A flag indicating if the key is compressed.value_is_compressed
: A flag indicating if the value is compressed.is_removed
: A flag indicating if the entry has been removed.CRC32
: The CRC32 checksum of the entry (including its header), stored in 4 bytes.KEY
: The key dataVALUE
: The value dataIncomplete Work
Currently the Rust code is compiled as a dynamic library:
Compiling and running Mina requires the user to set manually
LD_LIBRARY_PATH=_build/default/src/lib/keyvaluedb_rust/
We can't compile it statically because
proof-systems
is a static library, and using 2 Rust static libraries doesn't seem to be supported.An alternative would be to make use of OCaml virtual library, in the same way than kimchi
Checklist: