-
Notifications
You must be signed in to change notification settings - Fork 457
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
Turn BlockCursor::{read_blob,read_blob_into_buf} async fn #4905
Conversation
1588 tests run: 1512 passed, 0 failed, 76 skipped (full report)The comment gets automatically updated with the latest test results
564258f at 2023-08-14T14:30:12.923Z :recycle: |
tokio::sync:RwLock would be more appropriate. |
Yeah that's a bit scary from a performance point of view.
+1 that sounds better. Or even better, mark the whole |
At a quick glance, the functions that acquire the lock fall into two categories:
Async functions can easily just call |
Originally I tried using it, but it makes each acquiring of a lock
I'm not sure it's a good idea to do it before the actual underlying I/O operations are async: the task will otherwise block an entire task for the async scheduler. Even if the workload is CPU-bound, you should still yield back regularly to the executor via hitting an I suppose I'll then just move the entire loop into an async block. It's not optimal but better than having all of compaction in an async block. |
Okay, in response to feedback I have:
Also, I've merged latest main into this PR. |
## Problem In some places, the lock on `InMemoryLayerInner` is only created to obtain `end_lsn`. This is not needed however, if we move `end_lsn` to `InMemoryLayer` instead. ## Summary of changes Make `end_lsn` a member of `InMemoryLayer`, and do less locking of `InMemoryLayerInner`. `end_lsn` is changed from `Option<Lsn>` into an `OnceLock<Lsn>`. Thanks to this change, we don't need to lock any more in three functions. Part of #4743 . Suggested in #4905 (comment) .
791947e
to
99a755e
Compare
aff279e
to
564258f
Compare
Problem
The
BlockCursor::read_blob
andBlockCursor::read_blob_into_buf
functions are callingread_blk
internally, so if we want to make that function async fn, they need to be async themselves.Summary of changes
ValueRef::load
into an async fn.RwLock
implementation inInMemoryLayer
to use the one fromtokio
.read_blob
andread_blob_into_buf
functions into async fn.In three instances we use
Handle::block_on
:async
block to prevent the potentially hot loop from doing cross-thread operations.DeltaLayer
. The "proper" way to address this would be to enable the visit function to take async closures, but then we'd need to be generic over async fs non async, which isn't supported by rust right now. The other alternative would be to do a first pass where we cache the data into memory, and only then to dump it.Part of #4743
Checklist before requesting a review
Checklist before merging