mozilla / rkv

A simple, humane, typed key-value storage solution.
https://crates.io/crates/rkv
Apache License 2.0
307 stars 52 forks source link

Cow snapshots instead of always cloning #161

Closed victorporof closed 4 years ago

victorporof commented 4 years ago

To satisfy LMDB's semantics, querying or modifying individual transactions has certain behavior guarantees. Each transaction is a snapshot of the database; in other words, multiple read/write transactions are views into the database at the beginning of the transaction, altering or querying independent of each other.

To do this in safe mode, we create database snapshots when instantiating transactions (cloning on read). This is needlessly precautious, we can opt for cloning on write instead. This PR improves performance in case of large databases and the usual use of transactions.