Congyuwang / RocksDict

Python fast on-disk dictionary / RocksDB & SpeeDB Python binding
https://congyuwang.github.io/RocksDict/rocksdict.html
MIT License
173 stars 8 forks source link

Allow threading on get operations #103

Closed GodTamIt closed 8 months ago

GodTamIt commented 8 months ago

Before:

Get performance: 4194304 items in 13.99276754213497 seconds
Get performance multi-thread: 4194304 items in 13.610933708958328 seconds

After:

Get performance: 4194304 items in 14.377041833940893 seconds
Get performance multi-thread: 4194304 items in 5.503023374825716 seconds
Congyuwang commented 8 months ago

So, the improvement is mainly on batch_get right? Since batch_get usually needs more time. 👍

GodTamIt commented 8 months ago

Right, batch gets can run for an extended amount of time without having to re-acquire the GIL to access Python objects.

Individual get()s do not because they need the GIL to access the Python object values for the key and value every time. So if you do a get for a bunch of items, you're going to be contending on the lock for each iteration.

GodTamIt commented 8 months ago

For posterity, I'll comment here a few more details: