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

ImmutableDB: allow reading concurrently with appending #1907

Merged
merged 1 commit into from
Apr 6, 2020

Conversation

mrBliss
Copy link
Contributor

@mrBliss mrBliss commented Apr 6, 2020

Read the potentially stale value of the internal state provided by the
StrictMVar instead of blocking on the TMVar in case an appender has locked
it. Reads can safely happen concurrently with appends, so this will allow for
some more concurrency.

I don't expect this to make any impact for a "client" node that is syncing, as
it will typically not read from its ImmutableDB, only append to it, which is
necessarily sequential. However, a "server" node might have to read
headers/blocks from its ImmutableDB to serve to other nodes. Serving multiple
requests won't require taking + putting a TMVar anymore, it's just reading a
TVar now.

I expect to see the most improvement for a node serving others while it is
also still syncing itself. Blocks being appended to the ImmutableDB will
happen concurrently with all read requests.

Read the potentially stale value of the internal state provided by the
`StrictMVar` instead of blocking on the `TMVar` in case an appender has locked
it. Reads can safely happen concurrently with appends, so this will allow for
some more concurrency.

I don't expect this to make any impact for a "client" node that is syncing, as
it will typically not read from its ImmutableDB, only append to it, which is
necessarily sequential. However, a "server" node might have to read
headers/blocks from its ImmutableDB to serve to other nodes. Serving multiple
requests won't require taking + putting a `TMVar` anymore, it's just reading a
`TVar` now.

I expect to see the most improvement for a node serving others while it is
also still syncing itself. Blocks being appended to the ImmutableDB will
happen concurrently with all read requests.
@mrBliss mrBliss added the consensus issues related to ouroboros-consensus label Apr 6, 2020
@mrBliss mrBliss requested a review from edsko April 6, 2020 09:12
@mrBliss
Copy link
Contributor Author

mrBliss commented Apr 6, 2020

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Apr 6, 2020

@iohk-bors iohk-bors bot merged commit c3c1e52 into master Apr 6, 2020
@iohk-bors iohk-bors bot deleted the mrBliss/immutabledb-concurrency branch April 6, 2020 10:55
coot pushed a commit that referenced this pull request May 16, 2022
1900: Label mux threads r=karknu a=karknu



1907: ImmutableDB: allow reading concurrently with appending r=mrBliss a=mrBliss

Read the potentially stale value of the internal state provided by the
`StrictMVar` instead of blocking on the `TMVar` in case an appender has locked
it. Reads can safely happen concurrently with appends, so this will allow for
some more concurrency.

I don't expect this to make any impact for a "client" node that is syncing, as
it will typically not read from its ImmutableDB, only append to it, which is
necessarily sequential. However, a "server" node might have to read
headers/blocks from its ImmutableDB to serve to other nodes. Serving multiple
requests won't require taking + putting a `TMVar` anymore, it's just reading a
`TVar` now.

I expect to see the most improvement for a node serving others while it is
also still syncing itself. Blocks being appended to the ImmutableDB will
happen concurrently with all read requests.

Co-authored-by: Karl Knutsson <[email protected]>
Co-authored-by: Thomas Winant <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus issues related to ouroboros-consensus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants