From c6c7832b053b284df81ac5e6eb8da5428c496f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sun, 26 Nov 2023 15:52:36 +0100 Subject: [PATCH] Improve parsing of rustc artifacts The format of the artifacts was changed in a recent rustc PR, which broke rustc-perf's CI. --- collector/src/compile/execute/profiler.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/collector/src/compile/execute/profiler.rs b/collector/src/compile/execute/profiler.rs index 97be6ca34..03c2ab93f 100644 --- a/collector/src/compile/execute/profiler.rs +++ b/collector/src/compile/execute/profiler.rs @@ -298,15 +298,23 @@ impl<'a> Processor for ProfileProcessor<'a> { let tmp_eprintln_file = filepath(data.cwd, "eprintln"); let eprintln_file = filepath(self.output_dir, &out_file("eprintln")); + #[allow(dead_code)] + #[derive(serde::Deserialize)] + struct RustcMessage<'a> { + #[serde(rename = "$message_type")] + message_type: &'a str, + } + let mut final_file = io::BufWriter::new(std::fs::File::create(&eprintln_file)?); for line in io::BufReader::new(std::fs::File::open(&tmp_eprintln_file)?).lines() { let line = line?; + // rustc under Cargo currently ~always emits artifact // messages -- which we don't want in final - // eprintln output. These messages generally look like: - // {"artifact":"/tmp/.tmpjIe45J/...","emit":"dep-info"} - if line.starts_with(r#"{"artifact":"#) { + // eprintln output. These messages contain a $message_type tag since + // https://github.com/rust-lang/rust/pull/115691. + if serde_json::from_str::(&line).is_ok() { continue; }