-
Notifications
You must be signed in to change notification settings - Fork 11
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
Make Db::new async, force use of new API #323
Conversation
This somewhat-large diff pushes some of the async down the stack a little. It's not complete but it's a good stop point for the next push down.
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.
I know you've already pushed changes, but I figure I will leave this review here now anyway
This eliminates a lot of complexity, but callers must still import the api::* in order to use the db object.
This leaves metrics not working; we need a reference to the Db object from a DbRev in order for that to be fixed Calling revision(hash) on the root hash after creating an empty database fails. This can and should be fixed.
These need to happen whenever IO happens, these few spots were missed
Signed-off-by: Ron Kuris <ron.kuris@avalabs.org>
- Fix extra async during benchmarks - Make sure we always use CARGO_TARGET_DIR (not CARGO_TARGET_TMPDIR) (the latter only works during integration tests) - Add back concurrent insert tests (even though they probably will always work)
Co-authored-by: Richard Pringle <richard.pringle@avalabs.org> Signed-off-by: Ron Kuris <swcafe@gmail.com>
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.
I'm going to approve this, but I really don't think the changes in firewood/src/storage/buffer.rs
should be checked in. Tests should only be made async
on an as-needed basis.
firewood/src/storage/buffer.rs
Outdated
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.
I don't think these changes should be committed, there's no benefit to them. We should only make tests async that actually need to be async. We can do that on an as-needed basis.
I really don't think this code should be merged, to be honest. There's no reason for it. You can just stash these changes locally and re-apply them when you need them.
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.
The problem is that a future diff will make these functions wait for I/O and will need to support async. I'm just getting an early start.
@@ -172,7 +174,7 @@ pub trait DbView { | |||
/// [DbView], which means you can fetch values from it or | |||
/// obtain proofs. | |||
#[async_trait] | |||
pub trait Proposal: DbView { | |||
pub trait Proposal: DbView + Send + Sync { |
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.
➜ firewood git:(main) gh pr checkout 323
Switched to branch 'rkuris/async-down-stack'
Your branch is up to date with 'origin/rkuris/async-down-stack'.
Already up to date.
➜ firewood git:(rkuris/async-down-stack) sd '(DbView) \+ Send \+ Sync' '$1' firewood/src/v2/api.rs
➜ firewood git:(rkuris/async-down-stack) ✗ git --no-pager diff
diff --git a/firewood/src/v2/api.rs b/firewood/src/v2/api.rs
index 0ddacbe..dbc9ff4 100644
--- a/firewood/src/v2/api.rs
+++ b/firewood/src/v2/api.rs
@@ -172,7 +172,7 @@ pub trait DbView {
/// [DbView], which means you can fetch values from it or
/// obtain proofs.
#[async_trait]
-pub trait Proposal: DbView + Send + Sync {
+pub trait Proposal: DbView {
type Proposal: DbView + Proposal;
/// Commit this revision
➜ firewood git:(rkuris/async-down-stack) ✗ cargo check -p firewood
Checking firewood v0.0.4 (/<omitted>/firewood/firewood)
Finished dev [unoptimized + debuginfo] target(s) in 0.40s
➜ firewood git:(rkuris/async-down-stack) ✗
FYI
This might not be the case for you, but I never remember how to use sed
, I much prefer sd
.
ripgrep
is also much better than grep
😉
}); | ||
let (first, second) = tokio::join!(t1, t2); | ||
first.unwrap(); | ||
second.unwrap(); |
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.
👍
I swear I hit the approve button... weird. But |
This reverts commit 3a63859.
Signed-off-by: Ron Kuris <ron.kuris@avalabs.org>
This somewhat-large diff pushes some of the async down the stack a little. It's not complete but it's a good stop point for the next push down.