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

Don't block on glyph order if you don't have to #565

Merged
merged 1 commit into from
Nov 14, 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
2 changes: 1 addition & 1 deletion fontc/src/change_detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl ChangeDetector {
prev_inputs: Input,
timer: &mut JobTimer,
) -> Result<ChangeDetector, Error> {
let time = create_timer(AnyWorkId::InternalTiming("new change detector"))
let time = create_timer(AnyWorkId::InternalTiming("new change detector"), 0)
.queued()
.run();

Expand Down
4 changes: 2 additions & 2 deletions fontc/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ pub enum Error {
TasksFailed(Vec<(AnyWorkId, String)>),
#[error("Invalid regex")]
BadRegex(#[from] regex::Error),
#[error("Unable to proceed")]
UnableToProceed,
#[error("Unable to proceed; {0} jobs stuck pending")]
UnableToProceed(usize),
}
2 changes: 1 addition & 1 deletion fontc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ pub fn create_workload(
change_detector: &mut ChangeDetector,
timer: JobTimer,
) -> Result<Workload, Error> {
let time = create_timer(AnyWorkId::InternalTiming("Create workload"))
let time = create_timer(AnyWorkId::InternalTiming("Create workload"), 0)
.queued()
.run();
let mut workload = change_detector.create_workload(timer)?;
Expand Down
4 changes: 2 additions & 2 deletions fontc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn main() {

fn run() -> Result<(), Error> {
let mut timer = JobTimer::new(Instant::now());
let time = create_timer(AnyWorkId::InternalTiming("Init logger"))
let time = create_timer(AnyWorkId::InternalTiming("Init logger"), 0)
.queued()
.run();
env_logger::builder()
Expand All @@ -43,7 +43,7 @@ fn run() -> Result<(), Error> {
.init();
timer.add(time.complete());

let time = create_timer(AnyWorkId::InternalTiming("Init config"))
let time = create_timer(AnyWorkId::InternalTiming("Init config"), 0)
.queued()
.run();
let args = Args::parse();
Expand Down
33 changes: 25 additions & 8 deletions fontc/src/timing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{collections::HashMap, io, thread::ThreadId, time::Instant};

/// Tracks time for jobs that run on many threads.
///
/// Meant for use with a threadpool. For example, build up [JobTime] for each
/// Meant for use with a threadpool. For example, build timing for each
/// unit of work submitted to something like rayon and accumulate them here.
///
/// Currently not threadsafe, meant to be used by a central orchestrator because
Expand Down Expand Up @@ -76,6 +76,7 @@ impl JobTimer {
for timing in timings {
let job_start = (timing.run - self.t0).as_secs_f64();
let job_end = (timing.complete - self.t0).as_secs_f64();
let job_queued = (timing.queued - self.t0).as_secs_f64();
let begin_pct = 100.0 * job_start / end_time.as_secs_f64();
let exec_pct =
100.0 * (timing.complete - timing.run).as_secs_f64() / end_time.as_secs_f64();
Expand All @@ -96,10 +97,13 @@ impl JobTimer {
}
writeln!(
out,
"<title>{:.2}s ({:.2}%) {:?}</title>",
job_end - job_start,
"<title>{:.0}ms ({:.2}%) {:?}\nqueued at {:.0}ms\nrun at {:.0}ms\nWave {}</title>",
1000.0 * (job_end - job_start),
exec_pct,
timing.id
timing.id,
1000.0 * job_queued,
1000.0 * job_start,
timing.nth_wave,
)
.unwrap();
writeln!(out, " </g>").unwrap();
Expand Down Expand Up @@ -189,9 +193,14 @@ fn color(id: &AnyWorkId) -> &'static str {
///
/// Meant to be called when a job is runnable, that is it's ready to be
/// submitted to an execution system such as a threadpool.
pub fn create_timer(id: AnyWorkId) -> JobTimeRunnable {
///
/// nth_wave shows on mouseover in the final output. Each time we release
/// a group of jobs - because their dependencies are complate - we increment
/// it so one can see the graph progression in the timing svg output.
pub fn create_timer(id: AnyWorkId, nth_wave: usize) -> JobTimeRunnable {
rsheeter marked this conversation as resolved.
Show resolved Hide resolved
JobTimeRunnable {
id,
nth_wave,
runnable: Instant::now(),
}
}
Expand All @@ -201,6 +210,7 @@ pub fn create_timer(id: AnyWorkId) -> JobTimeRunnable {
/// It may have queued from t0 to launchable but now it's go-time!
pub struct JobTimeRunnable {
id: AnyWorkId,
nth_wave: usize,
runnable: Instant,
}

Expand All @@ -209,6 +219,7 @@ impl JobTimeRunnable {
pub fn queued(self) -> JobTimeQueued {
JobTimeQueued {
id: self.id,
nth_wave: self.nth_wave,
runnable: self.runnable,
queued: Instant::now(),
}
Expand All @@ -217,6 +228,7 @@ impl JobTimeRunnable {

pub struct JobTimeQueued {
id: AnyWorkId,
nth_wave: usize,
runnable: Instant,
queued: Instant,
}
Expand All @@ -229,6 +241,7 @@ impl JobTimeQueued {
pub fn run(self) -> JobTimeRunning {
JobTimeRunning {
id: self.id,
nth_wave: self.nth_wave,
thread: std::thread::current().id(),
runnable: self.runnable,
queued: self.queued,
Expand All @@ -239,6 +252,7 @@ impl JobTimeQueued {

pub struct JobTimeRunning {
id: AnyWorkId,
nth_wave: usize,
thread: ThreadId,
runnable: Instant,
queued: Instant,
Expand All @@ -252,9 +266,10 @@ impl JobTimeRunning {
pub fn complete(self) -> JobTime {
JobTime {
id: self.id,
nth_wave: self.nth_wave,
thread_id: self.thread,
_runnable: self.runnable,
_queued: self.queued,
queued: self.queued,
run: self.run,
complete: Instant::now(),
}
Expand All @@ -265,9 +280,10 @@ impl JobTimeRunning {
#[derive(Debug)]
pub struct JobTime {
id: AnyWorkId,
nth_wave: usize,
thread_id: ThreadId,
_runnable: Instant,
_queued: Instant,
queued: Instant,
run: Instant,
complete: Instant,
}
Expand All @@ -278,9 +294,10 @@ impl JobTime {
let now = Instant::now();
JobTime {
id,
nth_wave: 0,
thread_id: std::thread::current().id(),
_runnable: now,
_queued: now,
queued: now,
run: now,
complete: now,
}
Expand Down
Loading