Skip to content

Commit 43e8c0d

Browse files
committed
Don't pointlessly block on glyph order.
Add a few things to timing output to make it more helpful.
1 parent 0a00caa commit 43e8c0d

6 files changed

Lines changed: 157 additions & 83 deletions

File tree

fontc/src/change_detector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl ChangeDetector {
5959
prev_inputs: Input,
6060
timer: &mut JobTimer,
6161
) -> Result<ChangeDetector, Error> {
62-
let time = create_timer(AnyWorkId::InternalTiming("new change detector"))
62+
let time = create_timer(AnyWorkId::InternalTiming("new change detector"), 0)
6363
.queued()
6464
.run();
6565

fontc/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ pub enum Error {
2121
TasksFailed(Vec<(AnyWorkId, String)>),
2222
#[error("Invalid regex")]
2323
BadRegex(#[from] regex::Error),
24-
#[error("Unable to proceed")]
25-
UnableToProceed,
24+
#[error("Unable to proceed; {0} jobs stuck pending")]
25+
UnableToProceed(usize),
2626
}

fontc/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ pub fn create_workload(
293293
change_detector: &mut ChangeDetector,
294294
timer: JobTimer,
295295
) -> Result<Workload, Error> {
296-
let time = create_timer(AnyWorkId::InternalTiming("Create workload"))
296+
let time = create_timer(AnyWorkId::InternalTiming("Create workload"), 0)
297297
.queued()
298298
.run();
299299
let mut workload = change_detector.create_workload(timer)?;

fontc/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn main() {
2323

2424
fn run() -> Result<(), Error> {
2525
let mut timer = JobTimer::new(Instant::now());
26-
let time = create_timer(AnyWorkId::InternalTiming("Init logger"))
26+
let time = create_timer(AnyWorkId::InternalTiming("Init logger"), 0)
2727
.queued()
2828
.run();
2929
env_logger::builder()
@@ -43,7 +43,7 @@ fn run() -> Result<(), Error> {
4343
.init();
4444
timer.add(time.complete());
4545

46-
let time = create_timer(AnyWorkId::InternalTiming("Init config"))
46+
let time = create_timer(AnyWorkId::InternalTiming("Init config"), 0)
4747
.queued()
4848
.run();
4949
let args = Args::parse();

fontc/src/timing.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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}%) {:?}\nqueued at {:.0}ms\nrun at {:.0}ms\nWave {}</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!
202211
pub 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

218229
pub 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

240253
pub 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)]
266281
pub 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

Comments
 (0)