Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to reduce contention between readers & writer in NodeDB #2

Merged
merged 3 commits into from
May 30, 2019

Conversation

enlight
Copy link

@enlight enlight commented May 30, 2019

Previously there was a single mutex that had to be acquired by a
reader/writer before they could access either the node cache or the
underlying DB. These changes introduce a second mutex to synchronize
access to the node cache, while the original mutex is now only used to
synchronize write access to the underlying DB.

Multiple readers may now access the underlying DB concurrently, this
should work with GoLevelDB at least since it supports concurrent readers.

This makes it possible to persist leaf node values separately from the
tree nodes themselves. As leaf nodes are loaded their values are read
from the external store, when they're persisted to disk the values are
omitted. The external value store needs to be updated separately when
a key is set or deleted in the MutableTree.
Previously there was a single mutex that had to be acquired by a
reader/writer before they could access either the node cache or the
underlying DB. These changes introduce a second mutex to synchronize
access to the node cache, while the original mutex is now only used to
synchronize write access to the underlying DB.

Multiple readers may now access the underlying DB concurrently, this
should work with GoLevelDB at least since it supports concurrent readers.
The multi-mutex NodeDB is now called NodeDB2, both the new
implementation and the old one implement the new NodeDB interface.
MutableTree & ImmutableTree have been modified to only interact with the
NodeDB interface, so they can be used with either of the two NodeDB
implementations.
@enlight enlight merged commit 8c8fc7c into loomchain May 30, 2019
@enlight enlight deleted the multi-mutex-nodedb branch May 30, 2019 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant