Bucket in SQLite, draw the build-time bootstrap once, start sccache's server

Speed: the chart's counts come from GROUP BY over the bucket number, so
about 120 rows per table per range reach Rust instead of every saved row;
a range total is one indexed SUM. History counts the rows it hands out.

Build times: crates/stats gains Resampled, which draws the bootstrap once
for a set of languages and applies it to any number of hit sets; the
server keeps it and redraws only when an observation was added. The
views fill build_times, time saved and the 90% interval from the stats
crate, and the time-saved arithmetic of the server is gone.

Starting sccache: when nothing listens where the client looks
(SCCACHE_SERVER_UDS, or 127.0.0.1 at SCCACHE_SERVER_PORT), sccache
--start-server is run once and the counters read again; a failure is
reported as NotRunning and not retried for a minute.

Uses the api's Range::ALL, parse and label.
This commit is contained in:
swaits committed 2026-11-28 11:57:10 -07:00
1 parent 90a6302149
commit 16ba94517b
7 files changed
+1523 -473

No files matched your search

+368 -201
View File
@@ -1,15 +1,14 @@
//! Turning the saved history into the five `View`s the page draws, one per range. They are made
//! after every poll and kept; a request never waits for the database.
use std::collections::BTreeMap;
use sccache_dash_api::{
Bucket, Language, Problem, Range, Server, Severity, Status, TimeSaved, Timing, View,
Bucket, BuildTimes, Language, Problem, Range, Server, Severity, Status, TimeSaved, Timing, View,
};
use sccache_dash_stats::{LanguageHits, Observation, Resampled, Saved};
use serde_json::Value;
use crate::app::{State, RANGES};
use crate::history::{History, Row};
use crate::app::State;
use crate::history::{BucketLangs, BucketRow, History, Row};
use crate::pretty;
use crate::stats::{self, Counters, CACHE_WRITE, COMPILE, HIT_READ};
@@ -55,22 +54,197 @@ fn soft<T: Default>(result: rusqlite::Result<T>) -> T {
}
}
/// What a compile of each language takes, from the build observations: the polls after which
/// every build that had finished was of that one language.
#[derive(Default)]
struct Learned(BTreeMap<String, (f64, u64)>);
/// All that the history says about how long a build of each language takes. The build-time data
/// is the same for every range, so its bootstrap is drawn here, once per change.
pub struct Builds {
/// The languages with observations, in the order their observations were given to the draws.
languages: Vec<String>,
obs: Vec<Vec<Observation>>,
/// Each language's histogram, sorted by compiles seen, largest first.
pub times: Vec<BuildTimes>,
/// Each language's average build time in seconds, when it has seen enough to be counted.
means: Vec<Option<f64>>,
draws: Resampled,
/// (how many observations there are, when the newest is dated) this was made from.
stamp: Option<(i64, i64)>,
}
impl Learned {
/// (average build time in seconds, compiles it was learned from).
fn build_time(&self, lang: &str) -> Option<(f64, u64)> {
let (seconds, n) = self.0.get(lang).filter(|(_, n)| *n > 0)?;
Some((*seconds / *n as f64, *n))
impl Default for Builds {
fn default() -> Self {
Self::new()
}
}
impl Builds {
/// Nothing learned yet.
pub fn new() -> Builds {
Builds {
languages: Vec::new(),
obs: Vec::new(),
times: Vec::new(),
means: Vec::new(),
draws: Resampled::new(&[]),
stamp: None,
}
}
/// Takes in any observations added since the last look, and when there are some works out
/// the histograms and draws the bootstrap again: once per change, not once per range.
pub fn refresh(&mut self, h: &History) {
let stamp = soft(h.build_obs_stamp());
if self.stamp == Some(stamp) {
return;
}
let added = match self.stamp {
// Rows were only added: read just those.
Some((count, newest)) if stamp.0 > count && stamp.1 >= newest => {
soft(h.build_obs_after(newest))
}
_ => {
self.languages.clear();
self.obs.clear();
soft(h.build_obs_after(i64::MIN))
}
};
for (language, observation) in added {
let known = self.languages.iter().position(|l| *l == language);
let i = known.unwrap_or_else(|| {
self.languages.push(language.clone());
self.obs.push(Vec::new());
self.languages.len() - 1
});
self.obs[i].push(observation);
}
let mut times: Vec<BuildTimes> = self
.languages
.iter()
.enumerate()
.map(|(i, l)| sccache_dash_stats::build_times(l, &self.obs[i]))
.collect();
self.means = (0..self.languages.len())
.map(|i| counted(&self.obs[i]).then_some(times[i].mean_ms / 1000.0))
.collect();
times.sort_by(|a, b| {
b.compiles
.cmp(&a.compiles)
.then_with(|| a.language.cmp(&b.language))
});
let obs: Vec<&[Observation]> = self.obs.iter().map(Vec::as_slice).collect();
self.draws = Resampled::new(&obs);
self.times = times;
self.stamp = Some(stamp);
}
/// Time saved for one range's hits, from the draws already made.
fn saved(&self, hits: &[(String, [u64; 3])], hit_read: f64) -> Saved {
let mut unknown = 0;
let langs: Vec<LanguageHits<'_>> = self
.languages
.iter()
.enumerate()
.map(|(i, name)| LanguageHits {
hits: hits
.iter()
.find(|(n, _)| n == name)
.map_or(0, |(_, v)| v[0]),
obs: &self.obs[i],
})
.collect();
for (name, v) in hits {
if !self.languages.iter().any(|l| l == name) {
unknown += v[0];
}
}
let saved = self.draws.time_saved(&langs, hit_read);
Saved {
hits_left_out: saved.hits_left_out + unknown,
..saved
}
}
/// What one hit of this language saves on average, for the chart; `None` when the language
/// is left out.
fn saving(&self, language: &str, hit_read: f64) -> Option<f64> {
Some((self.means[self.languages.iter().position(|l| l == language)?]? - hit_read).max(0.0))
}
/// How the figure was reached, in plain words with the numbers used.
fn note(&self, hits: &[(String, [u64; 3])], hit_read: f64, saved: &Saved) -> String {
let counted: Vec<String> = hits
.iter()
.filter(|(name, v)| v[0] > 0 && self.saving(name, 0.0).is_some())
.map(|(name, _)| {
let i = self
.languages
.iter()
.position(|l| l == name)
.expect("a language with hits");
let t = &self
.times
.iter()
.find(|t| t.language == *name)
.expect("its histogram");
format!(
"{} {} (from {} builds)",
name,
pretty::short(self.means[i].unwrap_or(0.0)),
pretty::thousands(t.compiles)
)
})
.collect();
let mut left_out: Vec<(u64, &String)> = hits
.iter()
.filter(|(name, v)| v[0] > 0 && self.saving(name, 0.0).is_none())
.map(|(name, v)| (v[0], name))
.collect::<Vec<_>>();
left_out.sort_by(|a, b| b.0.cmp(&a.0).then_with(|| a.1.cmp(b.1)));
let left_out: Vec<String> = left_out
.iter()
.map(|(hits, name)| format!("{} {name}", pretty::thousands(*hits)))
.collect();
if hits.iter().all(|(_, v)| v[0] == 0) {
return "There were no hits in this range, so nothing was saved.".to_owned();
}
if counted.is_empty() {
return format!(
"Nothing is counted: no language has {} build times seen yet, each the average over the builds that finished between two polls ten seconds apart. {} hits left out.",
sccache_dash_stats::MIN_OBSERVATIONS,
pretty::thousands(saved.hits_left_out)
);
}
let mut note = format!(
"Learned build times: {}. A hit saves that minus the {} average cache read",
counted.join(", "),
pretty::short(hit_read)
);
if let Some((lo, hi)) = saved.interval_90 {
note.push_str(&format!(
"; in 9 of 10 such draws the total falls between {} and {}",
pretty::hours_and_minutes(lo),
pretty::hours_and_minutes(hi)
));
}
note.push('.');
if !left_out.is_empty() {
note.push_str(&format!(
" Left out: {} hits, too few build times seen to count.",
left_out.join(", ")
));
}
note
}
}
/// Whether a language has seen enough usable observations for its saving to be counted.
fn counted(obs: &[Observation]) -> bool {
obs.iter()
.filter(|o| o.compiles > 0 && o.seconds.is_finite() && o.seconds >= 0.0)
.count()
>= sccache_dash_stats::MIN_OBSERVATIONS
}
/// What every range needs the same way, gathered once per poll.
struct Known {
learned: Learned,
/// What the live reading adds since the last saved row, dated when it was read.
pending: Option<Row>,
server: Server,
@@ -92,13 +266,12 @@ fn gather(h: &History, st: &State, now: i64) -> Known {
.is_some_and(|p| p.delta.totals.requests > 0)
|| soft(h.requests_since(since + 1)) > 0;
Known {
learned: Learned(soft(h.build_time_totals())),
pending,
server: Server {
status: match live {
None => Status::NotRunning,
Some(_) if changed_recently => Status::Running,
Some(_) => Status::Idle,
status: match (live, st.error.as_ref()) {
(None, _) | (_, Some(_)) => Status::NotRunning,
(Some(_), None) if changed_recently => Status::Running,
(Some(_), None) => Status::Idle,
},
version: live.and_then(|l| l.snapshot.version.clone()),
client_version: st.client_version.clone(),
@@ -110,146 +283,119 @@ fn gather(h: &History, st: &State, now: i64) -> Known {
}
}
/// The rough, deliberately low saving: a hit counts only when the build time of its language
/// is known. Also returns the average time a hit took to read, which the chart needs.
fn time_saved(c: &Counters, learned: &Learned) -> (TimeSaved, f64) {
let t = &c.totals;
let hit_read = if t.hits > 0 {
c.ns[HIT_READ] as f64 / t.hits as f64 / 1e9
} else {
0.0
};
let (mut seconds, mut left_out, mut used, mut unknown) = (0.0, 0, Vec::new(), Vec::new());
for (name, v) in &c.langs {
if v[0] == 0 {
continue;
}
match learned.build_time(name) {
Some((build, compiles)) => {
seconds += v[0] as f64 * (build - hit_read).max(0.0);
used.push(format!(
"{} {} (from {} compiles)",
name,
pretty::short(build),
pretty::thousands(compiles)
));
}
None => {
left_out += v[0];
unknown.push((v[0], name));
}
/// A language's hits and misses go into a bucket's list, and its saving into the bucket's.
fn add_language(
bucket: &mut Bucket,
name: &str,
hits: u64,
misses: u64,
builds: &Builds,
hit_read: f64,
) {
match bucket.languages.iter_mut().find(|(k, _, _)| k == name) {
Some((_, h, m)) => {
*h += hits;
*m += misses;
}
None => bucket.languages.push((name.to_owned(), hits, misses)),
}
let note = if t.hits == 0 {
"There were no hits in this range, so nothing was saved.".to_owned()
} else if used.is_empty() {
format!(
"Nothing is counted: no build time has been learned yet, which takes polls after which every build that finished was of one language. {} hits left out.",
pretty::thousands(left_out)
)
} else {
let mut note = format!(
"Learned build times: {}. A hit saves that minus the {} average cache read.",
used.join(", "),
pretty::short(hit_read)
);
if left_out > 0 {
unknown.sort_by(|a, b| b.0.cmp(&a.0).then_with(|| a.1.cmp(b.1)));
let names: Vec<String> = unknown
.iter()
.map(|(hits, name)| format!("{} {name}", pretty::thousands(*hits)))
.collect();
note.push_str(&format!(
" Left out: {} hits ({}), no build time learned for them yet.",
pretty::thousands(left_out),
names.join(", ")
));
}
note
};
(
TimeSaved {
seconds,
hits_left_out: left_out,
note,
interval_90: None,
},
hit_read,
)
bucket.saved_seconds += hits as f64 * builds.saving(name, hit_read).unwrap_or(0.0);
}
/// The chart: at most [`levels::BUCKETS`] buckets from `from` up to and including `to`, each
/// holding the rows dated in it. `live` says the service is running now, so `to` itself was seen.
fn buckets(
rows: &[&Row],
langs: &[(i64, String, u64, u64)],
/// What the chart of one range is drawn from: the rows and languages SQLite added up per
/// bucket of `chart.len` seconds from `chart.from`, and the live reading.
struct Chart<'a> {
rows: &'a [BucketRow],
langs: &'a [BucketLangs],
pending: Option<&'a Row>,
from: i64,
to: i64,
learned: &Learned,
hit_read: f64,
live: bool,
) -> Vec<Bucket> {
let span = (to - from).max(1);
let len = (span + levels::BUCKETS - 1) / levels::BUCKETS;
let count = ((span + len - 1) / len) as usize;
// The last bucket takes the moment `to` itself, which is always the live reading.
let bucket_of = |t: i64| (((t - from) / len) as usize).min(count - 1);
len: i64,
}
/// The chart: at most [`levels::BUCKETS`] buckets up to and including `now`. `live` says the
/// service is running now, so `now` itself was seen.
fn buckets(chart: Chart<'_>, now: i64, builds: &Builds, hit_read: f64, live: bool) -> Vec<Bucket> {
let count = (((now - chart.from).max(1) + chart.len - 1) / chart.len) as usize;
// The last bucket takes the moment `now` itself, which is always the live reading.
let bucket_of = |t: i64| (((t - chart.from) / chart.len) as usize).min(count - 1);
let mut out: Vec<Bucket> = (0..count as i64)
.map(|i| Bucket {
start: from + i * len,
start: chart.from + i * chart.len,
gap: true,
..Bucket::default()
})
.collect();
for row in rows {
if row.t < from || row.t > to {
continue;
}
let b = &mut out[bucket_of(row.t)];
let t = &row.delta.totals;
b.reset |= row.reset;
b.hits += t.hits;
b.misses += t.misses;
b.other += t.not_cacheable + t.unsupported_compiler + t.not_compile;
b.errors += t.errors();
let add = |b: &mut Bucket, hits: u64, misses: u64, other: u64, errors: u64, reset: bool| {
b.reset |= reset;
b.hits += hits;
b.misses += misses;
b.other += other;
b.errors += errors;
};
for r in chart.rows {
add(
&mut out[(r.b.max(0) as usize).min(count - 1)],
r.hits,
r.misses,
r.other,
r.errors,
r.reset,
);
}
for (t, name, hits, misses) in langs {
if *t < from || *t > to {
continue;
for l in chart.langs {
add_language(
&mut out[(l.b.max(0) as usize).min(count - 1)],
&l.language,
l.hits,
l.misses,
builds,
hit_read,
);
}
if let Some(p) = chart.pending.filter(|p| p.t >= chart.from && p.t <= now) {
let t = &p.delta.totals;
add(
&mut out[bucket_of(p.t)],
t.hits,
t.misses,
t.not_cacheable + t.unsupported_compiler + t.not_compile,
t.errors(),
p.reset,
);
for (name, v) in &p.delta.langs {
add_language(&mut out[bucket_of(p.t)], name, v[0], v[1], builds, hit_read);
}
let b = &mut out[bucket_of(*t)];
match b.languages.iter_mut().find(|(k, _, _)| k == name) {
Some((_, h, m)) => {
*h += hits;
*m += misses;
}
None => b.languages.push((name.clone(), *hits, *misses)),
}
b.saved_seconds += *hits as f64
* learned
.build_time(name)
.map_or(0.0, |(build, _)| (build - hit_read).max(0.0));
}
// A bucket is open when a row falls in it, or when it lies between rows less than two
// minutes apart: rows come every minute while anything changes.
let mut times: Vec<i64> = rows
.iter()
.map(|r| r.t)
.filter(|&t| t >= from && t <= to)
.collect();
if live {
times.push(to);
}
for &t in &times {
out[bucket_of(t)].gap = false;
}
for w in times.windows(2) {
if w[1] - w[0] <= levels::GAP_SECS {
for b in &mut out[bucket_of(w[0])..bucket_of(w[1])] {
b.gap = false;
}
let mut first = vec![None::<i64>; count];
let mut last = vec![None::<i64>; count];
for r in chart.rows {
let i = (r.b.max(0) as usize).min(count - 1);
if first[i].is_none_or(|f| r.first < f) {
first[i] = Some(r.first);
}
if last[i].is_none_or(|l| r.last > l) {
last[i] = Some(r.last);
}
}
let mut previous = None;
for i in 0..count {
if let Some(l) = last[i] {
out[i].gap = false;
previous = Some(l);
continue;
}
let next = (i + 1..count)
.find_map(|j| first[j])
.or_else(|| live.then_some(now));
out[i].gap = !previous
.zip(next)
.is_some_and(|(p, n)| n - p <= levels::GAP_SECS);
}
if live {
out[count - 1].gap = false;
}
for b in &mut out {
b.languages.sort_by(|a, b| a.0.cmp(&b.0));
@@ -359,13 +505,7 @@ fn problems(c: &Counters, server: &Server) -> Vec<Problem> {
/// The text "Copy Summary" puts on the clipboard.
pub fn summary(view: &View) -> String {
let t = &view.totals;
let range = match view.range {
Some(Range::Hour) => "last hour",
Some(Range::Day) => "last 24 hours",
Some(Range::Week) => "last 7 days",
Some(Range::Month) => "last 30 days",
_ => "since last reset",
};
let range = view.range.map_or("", Range::label);
let hit_rate = match t.hit_rate() {
Some(r) => format!(
"{}% ({} of {} compiles from cache)",
@@ -403,8 +543,16 @@ pub fn summary(view: &View) -> String {
pretty::thousands(t.timeouts),
);
if view.time_saved.seconds > 0.0 {
let interval = match view.time_saved.interval_90 {
Some((lo, hi)) => format!(
"; 90% range {} \u{2013} {}",
pretty::hours_and_minutes(lo),
pretty::hours_and_minutes(hi)
),
None => String::new(),
};
s += &format!(
"- Time saved: ~{} (rough)\n",
"- Time saved: ~{} (rough{interval})\n",
pretty::hours_and_minutes(view.time_saved.seconds)
);
}
@@ -426,9 +574,16 @@ pub fn summary(view: &View) -> String {
}
/// Makes the view for one range.
fn compute(h: &History, known: &Known, st: &State, range: Range, now: i64) -> View {
fn compute(
h: &History,
builds: &Builds,
st: &State,
known: &Known,
range: Range,
now: i64,
) -> View {
let live = st.live.as_ref();
// When the chart starts: at the last zeroing for `reset`, a range's length back otherwise.
// When the chart starts: a range's length back, or at the last zeroing for `reset`.
let from = match range {
Range::SinceReset => soft(h.last_reset())
.or_else(|| soft(h.first_row()))
@@ -440,8 +595,7 @@ fn compute(h: &History, known: &Known, st: &State, range: Range, now: i64) -> Vi
} else {
now + 1
};
// The saved rows are read once: they make the totals and the chart, so the two always agree.
let saved = soft(h.rows(from, to));
let len = ((now - from).max(1) + levels::BUCKETS - 1) / levels::BUCKETS;
let (counters, previous) = match range {
// The counters as they are.
Range::SinceReset => (
@@ -449,32 +603,19 @@ fn compute(h: &History, known: &Known, st: &State, range: Range, now: i64) -> Vi
None,
),
_ => {
let mut counters = Counters::default();
for row in &saved {
counters.add(&row.delta);
}
let mut counters = soft(h.sums(from, to)).unwrap_or_default();
counters.langs = soft(h.languages(from, to));
counters.not_cached = soft(h.reasons(from, to));
if let Some(pending) = &known.pending {
counters.add(&pending.delta);
}
// The period of the same length just before: one indexed SUM.
(counters, soft(h.sums(now - 2 * length(range), from)))
(
counters,
soft(h.sums(now - 2 * length(range), from)).map(|p| p.totals),
)
}
};
let mut chart: Vec<&Row> = saved.iter().collect();
let mut langs = soft(h.language_rows(from, to));
if let Some(pending) = &known.pending {
chart.push(pending);
langs.extend(
pending
.delta
.langs
.iter()
.map(|(name, v)| (pending.t, name.clone(), v[0], v[1])),
);
}
let t = &counters.totals;
let per = |total_ns: u64, n: u64| (n > 0).then(|| total_ns as f64 / n as f64 / 1e6);
let timing = Timing {
@@ -482,7 +623,14 @@ fn compute(h: &History, known: &Known, st: &State, range: Range, now: i64) -> Vi
avg_cache_write_ms: per(counters.ns[CACHE_WRITE], t.cache_writes),
avg_compile_ms: per(counters.ns[COMPILE], counters.compilations),
};
let (time_saved, hit_read) = time_saved(&counters, &known.learned);
let hit_read = per(counters.ns[HIT_READ], t.hits).unwrap_or(0.0) / 1e3;
let saved = builds.saved(&counters.langs, hit_read);
let time_saved = TimeSaved {
seconds: saved.seconds,
hits_left_out: saved.hits_left_out,
interval_90: saved.interval_90,
note: builds.note(&counters.langs, hit_read, &saved),
};
let mut languages: Vec<Language> = counters
.langs
.iter()
@@ -513,29 +661,33 @@ fn compute(h: &History, known: &Known, st: &State, range: Range, now: i64) -> Vi
languages,
not_cached,
buckets: buckets(
&chart,
&langs,
from,
Chart {
rows: &soft(h.bucket_rows(from, len, to)),
langs: &soft(h.bucket_languages(from, len, to)),
pending: known.pending.as_ref(),
from,
len,
},
now,
&known.learned,
builds,
hit_read,
live.is_some(),
),
extras: live.map_or_else(Vec::new, |l| stats::extras(&l.snapshot)),
raw: st.raw.clone().unwrap_or(Value::Null),
summary_markdown: String::new(),
build_times: Vec::new(),
build_times: builds.times.clone(),
};
view.summary_markdown = summary(&view);
view
}
/// The five views, one per range of [`RANGES`], made after every poll.
pub fn all(h: &History, st: &State, now: i64) -> Vec<View> {
/// The five views, one per range, made after every poll.
pub fn all(h: &History, builds: &Builds, st: &State, now: i64) -> Vec<View> {
let known = gather(h, st, now);
RANGES
Range::ALL
.iter()
.map(|&range| compute(h, &known, st, range, now))
.map(|&range| compute(h, builds, st, &known, range, now))
.collect()
}
@@ -583,13 +735,15 @@ mod tests {
/// A saved history with a state, as the service has them.
struct Scene {
history: History,
builds: Builds,
state: State,
}
impl Scene {
fn view(&self, range: Range, now: i64) -> View {
all(&self.history, &self.state, now)[RANGES.iter().position(|r| *r == range).unwrap()]
.clone()
all(&self.history, &self.builds, &self.state, now)
[Range::ALL.iter().position(|r| *r == range).unwrap()]
.clone()
}
}
@@ -611,7 +765,13 @@ mod tests {
raw_text: text.to_owned(),
});
}
Scene { history, state }
let mut builds = Builds::new();
builds.refresh(&history);
Scene {
history,
builds,
state,
}
}
/// The readings, with a live reading at `at` that saw nothing change since the last of them.
@@ -933,24 +1093,25 @@ mod tests {
};
let history = History::memory().unwrap();
let mut tracker = Tracker::default();
for (t, misses) in [(0, 0), (10, 1), (70, 2), (130, 3)] {
for step in 0..12 {
let (t, misses) = (step * 10, step as u64);
history.record(&mut tracker, &taught(misses), t).unwrap();
}
let mut c = stats::parse(LIVE).unwrap().counters;
c.langs = vec![
("Assembler".to_owned(), [733, 0, 0]),
("C/C++".to_owned(), [2082, 0, 0]),
("Rust".to_owned(), [229, 3, 0]),
("Rust".to_owned(), [229, 11, 0]),
];
c.totals = Totals {
requests: 3047,
requests: 3055,
hits: 3044,
misses: 3,
cache_writes: 3,
misses: 11,
cache_writes: 11,
..Totals::default()
};
c.compilations = 3;
c.ns = [3_044 * 500_000_000, 3_000_000_000, 3 * 60_000_000_000];
c.compilations = 11;
c.ns = [3_044 * 500_000_000, 11_000_000_000, 11 * 60_000_000_000];
let snapshot = stats::Snapshot {
counters: c,
..stats::parse(LIVE).unwrap()
@@ -959,7 +1120,13 @@ mod tests {
tracker: history.tracker(),
..State::default()
};
let mut scene = Scene { history, state };
let mut builds = Builds::new();
builds.refresh(&history);
let mut scene = Scene {
history,
builds,
state,
};
scene.state.live = Some(Live {
at: 240,
snapshot,
@@ -977,7 +1144,7 @@ mod tests {
assert_eq!(ts.hits_left_out, 2082 + 733);
assert_eq!(
ts.note,
"Learned build times: Rust 60 s (from 3 compiles). A hit saves that minus the 500 ms average cache read. Left out: 2,815 hits (2,082 C/C++, 733 Assembler), no build time learned for them yet."
"Learned build times: Rust 60 s (from 11 builds). A hit saves that minus the 500 ms average cache read; in 9 of 10 such draws the total falls between 3h 47m and 3h 47m. Left out: 2,082 C/C++, 733 Assembler hits, too few build times seen to count."
);
assert_eq!(v.timing.avg_hit_read_ms, Some(500.0));
assert_eq!(
@@ -1032,7 +1199,7 @@ mod tests {
);
assert!(
ts.note
.starts_with("Nothing is counted: no build time has been learned yet"),
.starts_with("Nothing is counted: no language has 10 build times seen yet"),
"{}",
ts.note
);
@@ -1060,12 +1227,12 @@ mod tests {
let v = taught().view(Range::Day, 240);
assert_eq!(
v.totals.hit_rate(),
Some(3044.0 / 3047.0),
Some(3044.0 / 3055.0),
"hits out of cacheable compiles"
);
assert_eq!(
v.totals.hit_rate_of_all(),
Some(3044.0 / 3047.0),
Some(3044.0 / 3055.0),
"here every request was a cacheable compile"
);
let mixed = Totals {
@@ -1084,10 +1251,10 @@ mod tests {
assert_eq!(
v.summary_markdown,
"**sccache, last 24 hours**\n\
- Hit rate: 99.9% (3,044 of 3,047 compiles from cache)\n\
- By language: C/C++ 100%, Assembler 100%, Rust 98.7%\n\
- Hit rate: 99.6% (3,044 of 3,055 compiles from cache)\n\
- By language: C/C++ 100%, Assembler 100%, Rust 95.4%\n\
- Not cacheable: 0 \u{b7} Errors: 0 \u{b7} Timeouts: 0\n\
- Time saved: ~3h 47m (rough)\n\
- Time saved: ~3h 47m (rough; 90% range 3h 47m \u{2013} 3h 47m)\n\
- Cache: local disk, 10.0 of 10.0 GB \u{b7} sccache 0.18.0\n"
);
assert!(taught()
@@ -1107,7 +1274,7 @@ mod tests {
plain.state.client_version = Some("0.18.0".to_owned());
assert_eq!(
plain.view(Range::SinceReset, 100).summary_markdown,
"**sccache, since last reset**\n\
"**sccache, since reset**\n\
- Hit rate: 49.5% (3,197 of 6,453 compiles from cache)\n\
- By language: Rust 6.6%, C/C++ 100%, Assembler 100%\n\
- Not cacheable: 856 \u{b7} Errors: 0 \u{b7} Timeouts: 0\n\