Skip to content
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

Add final cursor to exec stats #4146

Merged
merged 1 commit into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions massa-client/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ impl Output for ExecutionStats {
"\tActive cursor: {}",
Style::Protocol.style(self.active_cursor)
);
println!(
"\tFinal cursor: {}",
Style::Protocol.style(self.final_cursor)
);
}
}

Expand Down
1 change: 1 addition & 0 deletions massa-execution-exports/src/test_exports/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ impl ExecutionController for MockExecutionController {
final_block_count: 0,
final_executed_operations_count: 0,
active_cursor: Slot::new(0, 0),
final_cursor: Slot::new(0, 0),
}
}

Expand Down
3 changes: 2 additions & 1 deletion massa-execution-worker/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ impl ExecutionState {

/// Get execution statistics
pub fn get_stats(&self) -> ExecutionStats {
self.stats_counter.get_stats(self.active_cursor)
self.stats_counter
.get_stats(self.active_cursor, self.final_cursor)
}

/// Applies the output of an execution to the final execution state.
Expand Down
3 changes: 2 additions & 1 deletion massa-execution-worker/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl ExecutionStatsCounter {
}

/// get statistics
pub fn get_stats(&self, active_cursor: Slot) -> ExecutionStats {
pub fn get_stats(&self, active_cursor: Slot, final_cursor: Slot) -> ExecutionStats {
let current_time = MassaTime::now().expect("could not get current time");
let start_time = current_time.saturating_sub(self.time_window_duration);
let map_func = |pair: &(usize, MassaTime)| -> usize {
Expand All @@ -91,6 +91,7 @@ impl ExecutionStatsCounter {
time_window_start: start_time,
time_window_end: current_time,
active_cursor,
final_cursor,
}
}
}
3 changes: 3 additions & 0 deletions massa-models/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub struct ExecutionStats {
pub final_executed_operations_count: usize,
/// active execution cursor slot
pub active_cursor: Slot,
/// final execution cursor slot
pub final_cursor: Slot,
}

impl std::fmt::Display for ExecutionStats {
Expand All @@ -44,6 +46,7 @@ impl std::fmt::Display for ExecutionStats {
self.final_executed_operations_count
)?;
writeln!(f, "\tActive cursor: {}", self.active_cursor)?;
writeln!(f, "\tFinal cursor: {}", self.final_cursor)?;
Ok(())
}
}
Expand Down