Skip to content

Commit

Permalink
update sim-rs ΔQ comparison, adding more info to some events
Browse files Browse the repository at this point in the history
  • Loading branch information
rkuhn committed Jan 22, 2025
1 parent 4ecfaf5 commit e106cfe
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
8 changes: 4 additions & 4 deletions delta_q/comparison_rs.txt

Large diffs are not rendered by default.

17 changes: 12 additions & 5 deletions delta_q/diffusion.jq
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def read_log(in; gen; recv): reduce in as $in (
.[$type][$id] |= . as [$t, $l] | [$t, $l + [$time - $t]];
g // r // .
) | map_values(
(map(.[1]|length)|max) as $max |
(map(.[1]|length)|max|debug) as $max |
map_values(
.[1] | select(length == $max) | hist(10; 100; .[])
.[1] | select(length == $max) | hist(2; 100; .[])
)
);

Expand Down Expand Up @@ -61,8 +61,15 @@ def print: . as $all | [
"\(join("_")) := \($all | getpath($path))"
] | join("\n");

read_log(limit(1000000; inputs);
select(.event.tag=="generated")|[.event.kind, .event.id, .time_s];
select(.event.tag=="enteredstate")|[.event.kind, .event.id, .time_s])
# for Haskell output
#read_log(limit(1000000; inputs);
# select(.event.tag=="generated")|[.event.kind, .event.id, .time_s];
# select(.event.tag=="enteredstate")|[.event.kind, .event.id, .time_s])

# for Rust output
read_log(limit(10000000; inputs);
select(.message.type=="CpuTaskFinished" and .message.task_type=="InputBlockGenerated")|["IB", .message.extra, .time / 1000000000];
select(.message.type=="CpuTaskFinished" and .message.task_type=="InputBlockValidated")|["IB", .message.extra, .time / 1000000000])

| map_values(min_max)
| print
6 changes: 5 additions & 1 deletion sim-rs/sim-core/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ pub enum Event {
},
CpuTaskFinished {
task: CpuTaskId<Node>,
task_type: String,
extra: String,
},
CpuSubtaskStarted {
task: CpuTaskId<Node>,
Expand Down Expand Up @@ -230,9 +232,11 @@ impl EventTracker {
});
}

pub fn track_cpu_task_finished(&self, task_id: CpuTaskId) {
pub fn track_cpu_task_finished(&self, task_id: CpuTaskId, task_type: String, extra: String) {
self.send(Event::CpuTaskFinished {
task: self.to_task(task_id),
task_type,
extra,
});
}

Expand Down
16 changes: 15 additions & 1 deletion sim-rs/sim-core/src/sim/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ impl CpuTask {
}
.to_string()
}

fn extra(&self) -> String {
match self {
Self::TransactionValidated(_, _) => "".to_string(),
Self::PraosBlockGenerated(_) => "".to_string(),
Self::PraosBlockValidated(_, _) => "".to_string(),
Self::InputBlockGenerated(id) => id.header.id.to_string(),
Self::InputBlockValidated(_, id) => id.header.id.to_string(),
Self::EndorserBlockGenerated(_) => "".to_string(),
Self::EndorserBlockValidated(_, _) => "".to_string(),
Self::VoteBundleGenerated(_) => "".to_string(),
Self::VoteBundleValidated(_, _) => "".to_string(),
}
}
}

/// Things that can happen next for a node
Expand Down Expand Up @@ -330,7 +344,7 @@ impl Node {
let Some(task) = finished_task else {
continue;
};
self.tracker.track_cpu_task_finished(task_id);
self.tracker.track_cpu_task_finished(task_id, task.task_type(), task.extra());
match task {
CpuTask::TransactionValidated(from, tx) => self.propagate_tx(from, tx)?,
CpuTask::PraosBlockGenerated(block) => self.finish_generating_block(block)?,
Expand Down

0 comments on commit e106cfe

Please sign in to comment.