Skip to content

Commit

Permalink
refactor(collator): added exec messages buffer metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
SmaGMan committed Jul 12, 2024
1 parent 968bb77 commit e371baf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
21 changes: 12 additions & 9 deletions collator/src/collator/execution_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl ExecutionManager {
Self {
shard_id,
messages_buffer_limit,
message_groups: MessageGroups::new(group_limit, group_vert_size),
message_groups: MessageGroups::new(shard_id, group_limit, group_vert_size),
process_ext_messages: false,
ext_messages_reader_started: false,
process_new_messages: false,
Expand Down Expand Up @@ -426,10 +426,10 @@ impl MessagesExecutor {

let labels = &[("workchain", self.shard_id.workchain().to_string())];

let group_size = group.len();
let group_mean_vert_size = group
.messages_count()
.checked_div(group_size)
let group_horizontal_size = group.len();
let group_messages_count = group.messages_count();
let group_mean_vert_size = group_messages_count
.checked_div(group_horizontal_size)
.unwrap_or_default();
let mut group_max_vert_size = 0;

Expand All @@ -441,7 +441,7 @@ impl MessagesExecutor {
futures.push(self.execute_messages(shard_account_stuff, msgs));
}

let mut items = Vec::with_capacity(group_size);
let mut items = Vec::with_capacity(group_messages_count);
let mut ext_msgs_error_count = 0;

let mut max_account_msgs_exec_time = Duration::ZERO;
Expand Down Expand Up @@ -483,18 +483,21 @@ impl MessagesExecutor {
}

let mean_account_msgs_exec_time = total_exec_time
.checked_div(group_size as u32)
.checked_div(group_horizontal_size as u32)
.unwrap_or_default();

tracing::info!(target: tracing_targets::EXEC_MANAGER,
group_size, group_max_vert_size,
group_horizontal_size, group_max_vert_size,
total_exec_time = %format_duration(total_exec_time),
mean_account_msgs_exec_time = %format_duration(mean_account_msgs_exec_time),
max_account_msgs_exec_time = %format_duration(max_account_msgs_exec_time),
"execute_group",
);

metrics::gauge!("tycho_do_collate_one_tick_group_size", labels).set(group_size as f64);
metrics::gauge!("tycho_do_collate_one_tick_group_messages_count", labels)
.set(group_messages_count as f64);
metrics::gauge!("tycho_do_collate_one_tick_group_horizontal_size", labels)
.set(group_horizontal_size as f64);
metrics::gauge!("tycho_do_collate_one_tick_group_mean_vert_size", labels)
.set(group_mean_vert_size as f64);
metrics::gauge!("tycho_do_collate_one_tick_group_max_vert_size", labels)
Expand Down
14 changes: 13 additions & 1 deletion collator/src/collator/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,8 @@ pub struct Dequeued {

#[derive(Default)]
pub(super) struct MessageGroups {
shard_id: ShardIdent,

offset: u32,
max_message_key: InternalMessageKey,
groups: FastHashMap<u32, MessageGroup>,
Expand All @@ -912,8 +914,9 @@ pub(super) struct MessageGroups {
}

impl MessageGroups {
pub fn new(group_limit: usize, group_vert_size: usize) -> Self {
pub fn new(shard_id: ShardIdent, group_limit: usize, group_vert_size: usize) -> Self {
Self {
shard_id,
group_limit,
group_vert_size,
..Default::default()
Expand Down Expand Up @@ -1019,6 +1022,10 @@ impl MessageGroups {
}
}
}

let labels = [("workchain", self.shard_id.workchain().to_string())];
metrics::gauge!("tycho_do_collate_msgs_exec_buffer_messages_count", &labels)
.set(self.messages_count() as f64);
}

pub fn first_group_is_full(&self) -> bool {
Expand Down Expand Up @@ -1049,6 +1056,11 @@ impl MessageGroups {
if let Some(first_group) = self.groups.remove(&self.offset) {
self.int_messages_count -= first_group.int_messages_count;
self.ext_messages_count -= first_group.ext_messages_count;

let labels = [("workchain", self.shard_id.workchain().to_string())];
metrics::gauge!("tycho_do_collate_msgs_exec_buffer_messages_count", &labels)
.set(self.messages_count() as f64);

Some(first_group)
} else {
None
Expand Down
12 changes: 11 additions & 1 deletion scripts/gen-dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,13 +568,23 @@ def block_metrics() -> RowPanel:

def collator_execution_metrics() -> RowPanel:
metrics = [
create_gauge_panel(
"tycho_do_collate_msgs_exec_buffer_messages_count",
"Messages count in exec buffer",
labels=['workchain=~"$workchain"'],
),
create_gauge_panel(
"tycho_do_collate_exec_msgs_groups_per_block",
"Number of msgs groups per block",
labels=['workchain=~"$workchain"'],
),
create_gauge_panel(
"tycho_do_collate_one_tick_group_size",
"tycho_do_collate_one_tick_group_messages_count",
"One exec tick group messages count",
labels=['workchain=~"$workchain"'],
),
create_gauge_panel(
"tycho_do_collate_one_tick_group_vertical_size",
"One exec tick group horizontal size",
labels=['workchain=~"$workchain"'],
),
Expand Down

0 comments on commit e371baf

Please sign in to comment.