vmware / splinterdb

High Performance Embedded Key-Value Store
https://splinterdb.org
Apache License 2.0
673 stars 56 forks source link

Fix O_DIRECT and multi-threaded io_context issues #621

Closed rtjohnso closed 3 months ago

rtjohnso commented 3 months ago

Fixes issue #620

There were two related issues:

The first fix in this PR is to explicitly track the number of in progress IOs on each io_context, and to wait for them all to complete when a thread is shutting down. This accomodates the behavior of io_getevents() with O_DIRECT.

The second fix is to switch to per-process io_contexts, i.e. all the threads in a process share a single io_context. Thus, as long as one thread in the process continues to interact with splinter, IO completions will get handled.

Note the second fix still leaves open a problem in the multi-process context: If all the threads in one process stop interacting with splinter, then the IO completions for their IOs will never get handled, which can block threads in other processes. The ideal solution would be to have a single IO context for all threads across all processes, but that's not possible. The feasible solution (not implemented in this PR) would be to have a thread in each process that just loops, handling IO completion events.

netlify[bot] commented 3 months ago

Deploy Preview for splinterdb canceled.

Name Link
Latest commit 55e34570342eae84400fc088703147f2372dad22
Latest deploy log https://app.netlify.com/sites/splinterdb/deploys/661a226f795d22000875df15