-
Notifications
You must be signed in to change notification settings - Fork 501
Logging with Two Threads #370
Logging with Two Threads #370
Conversation
Codecov Report
@@ Coverage Diff @@
## master #370 +/- ##
==========================================
+ Coverage 87.17% 87.29% +0.11%
==========================================
Files 211 214 +3
Lines 7635 7761 +126
==========================================
+ Hits 6656 6775 +119
- Misses 979 986 +7
Continue to review full report at Codecov.
|
…log_serialize_two_threads
Benchmark numbers for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for this PR.
We will have more work to do here to remove singletons and to rework the thread registry logic a bit more. Particularly, I think how this will work with dependency injection will be somewhat tricky.
@GustavoAngulo can you open issues for those after we merge this? Also make an issue to update the wiki's storage engine design doc I guess...
Before this PR, our logging was single threaded. Buffers were pushed into a queue by transactions, the buffers were then popped from the queue, serialized, and persisted in disk. This is slow as we can perform the serialization and persisting in parallel.
This PR performs a large reformatting on the log manager. How transactions interact with the log manager remains the same. Transactions hand off buffers to the log manager, which are added to an internal queue. This minimizes the amount of time transactions spend interacting with the log manager.
The main change is the addition of two tasks running on dedicated threads (using the DedicatedThreadRegistry):
LogSerializerTask
: This task pops unserialized buffers from the internal unserialized buffer queue, serializes them, and adds them to a consumer queue to be consumed by the consumer task.DiskLogConsumerTask
: This task pops serialized buffers from the consumer queue and writes them to the log file. It will also persist the log file under certain conditions (periodically, we have written a significant amount of data since the last persist, or someone forces a flush). The task will also call any corresponding commit callbacks when it persists commit records.https://www.youtube.com/watch?v=oiY_iKSpWLM