From 10529cc768b35e82a43bae31dc382845028fed36 Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Thu, 14 Mar 2024 18:55:00 -0400 Subject: [PATCH] normalize_symbol_name: also strip numeric suffix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some symbols also have a numeric suffix, e.g. in `::fmt::h863044c0549d7049.60`. This results in spurious diffs, e.g. when running `./target/release/collector binary_stats +6f3eb1ce3d50246b2cbc5de3107c0f34889f5cc6 --rustc2 +2105ceeb0f23267f160392bd0e43b1c647590aac --include helloworld-tiny --profile Opt --backend Llvm --symbols`, I see: ``` │ ::fmt.60 │ 26 B │ 0 B │ -26 │ -100.0% │ │ ::fmt.72 │ 0 B │ 26 B │ +26 │ +100.0% │ ``` --- collector/src/artifact_stats.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/collector/src/artifact_stats.rs b/collector/src/artifact_stats.rs index 6eea672f9..b777d713c 100644 --- a/collector/src/artifact_stats.rs +++ b/collector/src/artifact_stats.rs @@ -95,7 +95,8 @@ static RUSTC_HASH_REGEX: OnceLock = OnceLock::new(); /// Demangle the symbol and remove rustc mangling hashes. fn normalize_symbol_name(symbol: &str) -> String { - let regex = RUSTC_HASH_REGEX.get_or_init(|| Regex::new(r#"(::)?\b[a-z0-9]{15,17}\b"#).unwrap()); + let regex = + RUSTC_HASH_REGEX.get_or_init(|| Regex::new(r#"(::)?\b[a-z0-9]{15,17}\b(\.\d+)?"#).unwrap()); let symbol = rustc_demangle::demangle(symbol).to_string(); regex.replace_all(&symbol, "").to_string()