@@ -8,7 +8,7 @@ use std::{collections::HashMap, io, thread::ThreadId, time::Instant};
88
99/// Tracks time for jobs that run on many threads.
1010///
11- /// Meant for use with a threadpool. For example, build up [JobTime] for each
11+ /// Meant for use with a threadpool. For example, build timing for each
1212/// unit of work submitted to something like rayon and accumulate them here.
1313///
1414/// Currently not threadsafe, meant to be used by a central orchestrator because
@@ -76,6 +76,7 @@ impl JobTimer {
7676 for timing in timings {
7777 let job_start = ( timing. run - self . t0 ) . as_secs_f64 ( ) ;
7878 let job_end = ( timing. complete - self . t0 ) . as_secs_f64 ( ) ;
79+ let job_queued = ( timing. queued - self . t0 ) . as_secs_f64 ( ) ;
7980 let begin_pct = 100.0 * job_start / end_time. as_secs_f64 ( ) ;
8081 let exec_pct =
8182 100.0 * ( timing. complete - timing. run ) . as_secs_f64 ( ) / end_time. as_secs_f64 ( ) ;
@@ -96,10 +97,13 @@ impl JobTimer {
9697 }
9798 writeln ! (
9899 out,
99- "<title>{:.2}s ({:.2}%) {:?}</title>" ,
100- job_end - job_start,
100+ "<title>{:.0}ms ({:.2}%) {:?} \n queued at {:.0}ms \n run at {:.0}ms \n Wave { }</title>" ,
101+ 1000.0 * ( job_end - job_start) ,
101102 exec_pct,
102- timing. id
103+ timing. id,
104+ 1000.0 * job_queued,
105+ 1000.0 * job_start,
106+ timing. nth_wave,
103107 )
104108 . unwrap ( ) ;
105109 writeln ! ( out, " </g>" ) . unwrap ( ) ;
@@ -189,9 +193,14 @@ fn color(id: &AnyWorkId) -> &'static str {
189193///
190194/// Meant to be called when a job is runnable, that is it's ready to be
191195/// submitted to an execution system such as a threadpool.
192- pub fn create_timer ( id : AnyWorkId ) -> JobTimeRunnable {
196+ ///
197+ /// nth_wave shows on mouseover in the final output. Each time we release
198+ /// a group of jobs - because their dependencies are complate - we increment
199+ /// it so one can see the graph progression in the timing svg output.
200+ pub fn create_timer ( id : AnyWorkId , nth_wave : usize ) -> JobTimeRunnable {
193201 JobTimeRunnable {
194202 id,
203+ nth_wave,
195204 runnable : Instant :: now ( ) ,
196205 }
197206}
@@ -201,6 +210,7 @@ pub fn create_timer(id: AnyWorkId) -> JobTimeRunnable {
201210/// It may have queued from t0 to launchable but now it's go-time!
202211pub struct JobTimeRunnable {
203212 id : AnyWorkId ,
213+ nth_wave : usize ,
204214 runnable : Instant ,
205215}
206216
@@ -209,6 +219,7 @@ impl JobTimeRunnable {
209219 pub fn queued ( self ) -> JobTimeQueued {
210220 JobTimeQueued {
211221 id : self . id ,
222+ nth_wave : self . nth_wave ,
212223 runnable : self . runnable ,
213224 queued : Instant :: now ( ) ,
214225 }
@@ -217,6 +228,7 @@ impl JobTimeRunnable {
217228
218229pub struct JobTimeQueued {
219230 id : AnyWorkId ,
231+ nth_wave : usize ,
220232 runnable : Instant ,
221233 queued : Instant ,
222234}
@@ -229,6 +241,7 @@ impl JobTimeQueued {
229241 pub fn run ( self ) -> JobTimeRunning {
230242 JobTimeRunning {
231243 id : self . id ,
244+ nth_wave : self . nth_wave ,
232245 thread : std:: thread:: current ( ) . id ( ) ,
233246 runnable : self . runnable ,
234247 queued : self . queued ,
@@ -239,6 +252,7 @@ impl JobTimeQueued {
239252
240253pub struct JobTimeRunning {
241254 id : AnyWorkId ,
255+ nth_wave : usize ,
242256 thread : ThreadId ,
243257 runnable : Instant ,
244258 queued : Instant ,
@@ -252,9 +266,10 @@ impl JobTimeRunning {
252266 pub fn complete ( self ) -> JobTime {
253267 JobTime {
254268 id : self . id ,
269+ nth_wave : self . nth_wave ,
255270 thread_id : self . thread ,
256271 _runnable : self . runnable ,
257- _queued : self . queued ,
272+ queued : self . queued ,
258273 run : self . run ,
259274 complete : Instant :: now ( ) ,
260275 }
@@ -265,9 +280,10 @@ impl JobTimeRunning {
265280#[ derive( Debug ) ]
266281pub struct JobTime {
267282 id : AnyWorkId ,
283+ nth_wave : usize ,
268284 thread_id : ThreadId ,
269285 _runnable : Instant ,
270- _queued : Instant ,
286+ queued : Instant ,
271287 run : Instant ,
272288 complete : Instant ,
273289}
@@ -278,9 +294,10 @@ impl JobTime {
278294 let now = Instant :: now ( ) ;
279295 JobTime {
280296 id,
297+ nth_wave : 0 ,
281298 thread_id : std:: thread:: current ( ) . id ( ) ,
282299 _runnable : now,
283- _queued : now,
300+ queued : now,
284301 run : now,
285302 complete : now,
286303 }
0 commit comments