-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat(collator): refactor message groups #316
base: master
Are you sure you want to change the base?
Conversation
d77124a
to
e318e94
Compare
6b35228
to
7e4283d
Compare
3528436
to
d16bfa3
Compare
Test: DEX -n 500 -r 1000. grafanaResultBlock Size (avg):Old: 15 - 20 MB Merkle Update (max):Old: 50 ms Finalize time (max):Old: 250-750 ms Collation time (max):Old: 750 ms - 1 s Block rates:Old: 2.59 New state prepare time (max):Old: 750 ms - 1 s Working state wait time (max):Old: 250-750 ms Read existing messages (max):Old: 250 ms Add messages to group (max):Old: 50 - 100 ms |
d16bfa3
to
5a76c5f
Compare
6359340
to
50fbf16
Compare
50fbf16
to
cc44bf7
Compare
collator/src/collator/mod.rs
Outdated
@@ -1273,6 +1279,10 @@ impl CollatorStdImpl { | |||
drop(histogram); | |||
self.do_collate(working_state, None).await?; | |||
} else { | |||
if !has_uprocessed_messages && !has_externals { |
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.
has_unprocessed_messages
pub fn extract_merged_group(&mut self) -> Option<MessageGroup> { | ||
let mut messages: Vec<(HashBytes, VecDeque<Message>)> = | ||
self.current_messages.drain().collect(); | ||
|
||
while let Some((key, val)) = self.new_messages_full.pop_first() { | ||
messages.push((key, val)); | ||
} | ||
|
||
while let Some((key, val)) = self.new_messages.pop_first() { | ||
messages.push((key, val)); | ||
} | ||
|
||
if messages.is_empty() { | ||
return None; | ||
} | ||
|
||
let group = MessageGroup::new( | ||
messages | ||
.into_iter() | ||
.map(|(h, m)| (h, m.into_iter().map(|m| m.inner).collect())) | ||
.collect(), | ||
self.int_messages_count, | ||
self.ext_messages_count, | ||
); | ||
|
||
tracing::debug!(target: tracing_targets::COLLATOR, | ||
"extracted merged message group of new messages from message_groups buffer: buffer int={}, ext={}, group {}", | ||
self.int_messages_count(), self.ext_messages_count(), | ||
DisplayMessageGroup(&group), | ||
); | ||
|
||
Some(group) | ||
} | ||
} |
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.
Shouldn't we update counters in self after moving messages into a new MessageGroup
?
new_messages: BTreeMap<HashBytes, VecDeque<Message>>, | ||
new_messages_full: BTreeMap<HashBytes, VecDeque<Message>>, |
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.
Can't it be changed to IndexMap
?
@@ -204,6 +209,7 @@ pub struct CollatorStdImpl { | |||
anchors_cache: AnchorsCache, | |||
stats: CollatorStats, | |||
timer: std::time::Instant, | |||
accounts_load: BTreeMap<AccountId, u32>, |
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.
Can't this be changed to HashMap
? It seems like order doesn't matter
22e11bd
to
96081e8
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #316 +/- ##
==========================================
+ Coverage 46.99% 47.13% +0.13%
==========================================
Files 240 241 +1
Lines 37403 37530 +127
Branches 37403 37530 +127
==========================================
+ Hits 17578 17688 +110
- Misses 18909 18924 +15
- Partials 916 918 +2 ☔ View full report in Codecov by Sentry. |
de646d9
to
bbf225b
Compare
bbf225b
to
f9f488c
Compare
No description provided.