File tree Expand file tree Collapse file tree 3 files changed +16
-17
lines changed Expand file tree Collapse file tree 3 files changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -166,7 +166,6 @@ impl EventMonitor {
166166 Event :: CpuTaskScheduled { .. } => { }
167167 Event :: CpuTaskFinished { .. } => { }
168168 Event :: CpuSubtaskStarted { .. } => { }
169- Event :: CpuSubtaskFinished { .. } => { }
170169 Event :: TransactionGenerated { id, bytes, .. } => {
171170 txs. insert ( id, Transaction :: new ( bytes, time) ) ;
172171 pending_txs. insert ( id) ;
Original file line number Diff line number Diff line change 1- use std:: { collections:: BTreeMap , fmt:: Display , sync:: Arc } ;
1+ use std:: { collections:: BTreeMap , fmt:: Display , sync:: Arc , time :: Duration } ;
22
3- use serde:: Serialize ;
3+ use serde:: { Serialize , Serializer } ;
44use tokio:: sync:: mpsc;
55use tracing:: warn;
66
@@ -72,10 +72,8 @@ pub enum Event {
7272 CpuSubtaskStarted {
7373 task : CpuTaskId < Node > ,
7474 subtask_id : u64 ,
75- } ,
76- CpuSubtaskFinished {
77- task : CpuTaskId < Node > ,
78- subtask_id : u64 ,
75+ #[ serde( serialize_with = "duration_as_nanos" ) ]
76+ duration : Duration ,
7977 } ,
8078 TransactionGenerated {
8179 id : TransactionId ,
@@ -243,17 +241,16 @@ impl EventTracker {
243241 } ) ;
244242 }
245243
246- pub fn track_cpu_subtask_started ( & self , task_id : CpuTaskId , subtask_id : u64 ) {
244+ pub fn track_cpu_subtask_started (
245+ & self ,
246+ task_id : CpuTaskId ,
247+ subtask_id : u64 ,
248+ duration : Duration ,
249+ ) {
247250 self . send ( Event :: CpuSubtaskStarted {
248251 task : self . to_task ( task_id) ,
249252 subtask_id,
250- } ) ;
251- }
252-
253- pub fn track_cpu_subtask_finished ( & self , task_id : CpuTaskId , subtask_id : u64 ) {
254- self . send ( Event :: CpuSubtaskFinished {
255- task : self . to_task ( task_id) ,
256- subtask_id,
253+ duration,
257254 } ) ;
258255 }
259256
@@ -475,3 +472,7 @@ impl EventTracker {
475472 }
476473 }
477474}
475+
476+ fn duration_as_nanos < S : Serializer > ( duration : & Duration , serializer : S ) -> Result < S :: Ok , S :: Error > {
477+ serializer. serialize_u128 ( duration. as_nanos ( ) )
478+ }
Original file line number Diff line number Diff line change @@ -295,7 +295,7 @@ impl Node {
295295 index : subtask. task_id ,
296296 } ;
297297 self . tracker
298- . track_cpu_subtask_started ( task_id, subtask. subtask_id ) ;
298+ . track_cpu_subtask_started ( task_id, subtask. subtask_id , subtask . duration ) ;
299299 let timestamp = self . clock . now ( ) + subtask. duration ;
300300 self . events . push ( FutureEvent (
301301 timestamp,
@@ -391,7 +391,6 @@ impl Node {
391391 NodeEvent :: MessageReceived ( from, msg) => self . handle_message( from, msg) ?,
392392 NodeEvent :: CpuSubtaskCompleted ( subtask) => {
393393 let task_id = CpuTaskId { node: self . id, index: subtask. task_id } ;
394- self . tracker. track_cpu_subtask_finished( task_id. clone( ) , subtask. subtask_id) ;
395394 let ( finished_task, next_subtask) = self . cpu. complete_subtask( subtask) ;
396395 if let Some ( subtask) = next_subtask {
397396 self . start_cpu_subtask( subtask) ;
You can’t perform that action at this time.
0 commit comments