-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[dag] concurrent dag store #11505
[dag] concurrent dag store #11505
Conversation
⏱️ 8h 12m total CI duration on this PR
🚨 1 job on the last run was significantly faster/slower than expected
|
Current dependencies on/for this PR:
This stack of pull requests is managed by Graphite. |
4d63114
to
97d4ab8
Compare
78bf7e0
to
2140a13
Compare
d314c8e
to
74562ed
Compare
consensus/src/dag/dag_store.rs
Outdated
} | ||
} | ||
|
||
pub fn write(&self) -> DagWriteGuard { |
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 think this is redundant
2140a13
to
39e4b84
Compare
a215a13
to
7f86eb9
Compare
60bacf0
to
78ffa8c
Compare
39e4b84
to
9480471
Compare
a6e6ee3
to
0d87fcc
Compare
consensus/src/dag/dag_driver.rs
Outdated
@@ -46,7 +44,7 @@ use tokio_retry::strategy::ExponentialBackoff; | |||
pub(crate) struct DagDriver { | |||
author: Author, | |||
epoch_state: Arc<EpochState>, | |||
dag: Arc<RwLock<Dag>>, | |||
dag: Arc<PersistentDagStore>, |
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.
dag -> persistenet_dag to avoid confusion with the inner dag?
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.
nit:
You could take
let round_ref = self
.nodes_by_round
.entry(round)
.or_insert_with(|| vec![None; self.author_to_index.len()]);
out of validate and lock only that.
Much cleaner now! |
Ok(()) | ||
} | ||
|
||
fn validate_new_node(&mut self, node: &CertifiedNode) -> anyhow::Result<()> { |
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.
hmm, it looks a bit weird to have &mut self for validation, but probably it makes insertion simpler
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.
yes, it makes insertion and also last validation step simpler.
consensus/src/dag/dag_store.rs
Outdated
@@ -408,3 +372,114 @@ impl Dag { | |||
self.nodes_by_round.is_empty() && self.start_round > 1 | |||
} | |||
} | |||
|
|||
pub struct PersistentDagStore { |
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'd call this DagStore and Dag -> InMemDag
let node = Arc::new(node); | ||
let round_ref = self | ||
.get_node_ref_mut(node.round(), node.author()) | ||
.expect("must be present"); |
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.
hmm, this is not true if pruning happens in between?
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.
yes, found this recently as well. we need a ensure! here for the round here. Also, need to fix the lowest_round() and highest_round() implementations.
9480471
to
0ffbe17
Compare
0d87fcc
to
e769867
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
Description
PersistentDagStore
handles both persistence and maintains the in-memory DAG store.Test Plan