alekcz / konserve-leveldb

A leveldb backend for konserve using clj-leveldb.
Eclipse Public License 2.0
5 stars 0 forks source link

Perf tradeoff reads vs writes #1

Closed alekcz closed 4 years ago

alekcz commented 4 years ago

I've changed the store to split layout. "/meta" and "/data" is added to keys and the we put and delete using transactions. We can the get-meta inexpensively.

The trade offs:

This means we're prioritising read performance which seems reasonable to me, especially because being able to only read the meta is critical for the GC.

whilo commented 4 years ago

Do you know whether it is actually twice as slow? I think putting both puts in one transaction could have similar performance than doing one large put, but that is just speculation.

alekcz commented 4 years ago

@whilo I'm not sure about the actual performance, my thinking is that two different reads means you touch disk twice. LevelDB probably does some optimisation under the hood, but I imagine if the data isn't cached we would have to go to disk.

whilo commented 4 years ago

I think if both keys land in the same index fragment of leveldb it could fetch them at once. So we should use the same UUID key prefix and distinguish the value by some suffix like -value for instance.

whilo commented 4 years ago

Here we did it the other way around, but that is not good for cache locality: https://github.com/FerdiKuehne/konserve-rocksdb/blob/feature_meta_data_support/src/konserve_rocksdb/core.clj#L126

alekcz commented 4 years ago

That makes sense. I went with "/" instead of "-". That way leveldb, rocksdb, couchdb and firebase will all use the same format, so to speak.

alekcz commented 4 years ago

I'll make this change to Rocksdb and push them both to clojars in the morning.