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

compiler cache stats now display information on a per lang+compiler basis #1893

Closed
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
4 changes: 4 additions & 0 deletions src/compiler/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ where
fn box_clone(&self) -> Box<dyn CompilerHasher<T>> {
Box::new((*self).clone())
}

fn language(&self) -> &'static str {
return self.parsed_args.language.as_str();
}
}

impl<I: CCompilerImpl> Compilation for CCompilation<I> {
Expand Down
16 changes: 11 additions & 5 deletions src/compiler/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,17 @@ pub enum CompilerKind {
}

impl CompilerKind {
pub fn lang_kind(&self) -> String {
pub fn lang_kind(&self, lang: &'static str) -> String {
let lang_and_compiler = lang.to_string();
match self {
CompilerKind::C(CCompilerKind::Nvcc) => "CUDA",
CompilerKind::C(_) => "C/C++",
CompilerKind::Rust => "Rust",
CompilerKind::C(CCompilerKind::Clang) => lang_and_compiler + " [clang]",
CompilerKind::C(CCompilerKind::Diab) => lang_and_compiler + " [diab]",
CompilerKind::C(CCompilerKind::Gcc) => lang_and_compiler + " [gcc]",
CompilerKind::C(CCompilerKind::Msvc) => lang_and_compiler + " [msvc]",
CompilerKind::C(CCompilerKind::Nvcc) => lang_and_compiler + " [nvcc]",
CompilerKind::C(CCompilerKind::TaskingVX) => lang_and_compiler + " [taskingVX]",
CompilerKind::Rust => "Rust".to_string(),
}
.to_string()
}
}

Expand Down Expand Up @@ -425,6 +429,8 @@ where
fn output_pretty(&self) -> Cow<'_, str>;

fn box_clone(&self) -> Box<dyn CompilerHasher<T>>;

fn language(&self) -> &'static str;
}

#[cfg(not(feature = "dist-client"))]
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,10 @@ where
fn box_clone(&self) -> Box<dyn CompilerHasher<T>> {
Box::new((*self).clone())
}

fn language(&self) -> &'static str {
return "Rust";
}
}

impl Compilation for RustCompilation {
Expand Down
17 changes: 9 additions & 8 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,7 @@ where
let color_mode = hasher.color_mode();
let me = self.clone();
let kind = compiler.kind();
let lang = hasher.language();
let creator = self.creator.clone();
let storage = self.storage.clone();
let pool = self.rt.clone();
Expand Down Expand Up @@ -1199,12 +1200,12 @@ where
CompileResult::Error => {
debug!("compile result: cache error");

stats.cache_errors.increment(&kind);
stats.cache_errors.increment(&kind, &lang);
}
CompileResult::CacheHit(duration) => {
debug!("compile result: cache hit");

stats.cache_hits.increment(&kind);
stats.cache_hits.increment(&kind, &lang);
stats.cache_read_hit_duration += duration;
}
CompileResult::CacheMiss(miss_type, dist_type, duration, future) => {
Expand All @@ -1229,18 +1230,18 @@ where
stats.cache_timeouts += 1;
}
MissType::CacheReadError => {
stats.cache_errors.increment(&kind);
stats.cache_errors.increment(&kind, &lang);
}
}
stats.cache_misses.increment(&kind);
stats.cache_misses.increment(&kind, &lang);
stats.compiler_write_duration += duration;
debug!("stats after compile result: {stats:?}");
cache_write = Some(future);
}
CompileResult::NotCacheable => {
debug!("compile result: not cacheable");

stats.cache_misses.increment(&kind);
stats.cache_misses.increment(&kind, &lang);
stats.non_cacheable_compilations += 1;
}
CompileResult::CompileFailed => {
Expand Down Expand Up @@ -1298,7 +1299,7 @@ where
error!("[{:?}] \t{}", out_pretty, e);
let _ = writeln!(error, "sccache: caused by: {}", e);
}
stats.cache_errors.increment(&kind);
stats.cache_errors.increment(&kind, &lang);
//TODO: figure out a better way to communicate this?
res.retcode = Some(-2);
res.stderr = error.into_bytes();
Expand Down Expand Up @@ -1353,8 +1354,8 @@ pub struct PerLanguageCount {
}

impl PerLanguageCount {
fn increment(&mut self, kind: &CompilerKind) {
let key = kind.lang_kind();
fn increment(&mut self, kind: &CompilerKind, lang: &'static str) {
let key = kind.lang_kind(lang);
let count = self.counts.entry(key).or_insert(0);
*count += 1;
}
Expand Down
Loading