From 169ef10d0d81a0fda6969e7d0f6d02ab915993ca Mon Sep 17 00:00:00 2001 From: Randy Stauner Date: Thu, 19 Feb 2026 11:15:14 -0700 Subject: [PATCH] Normalize hex addresses in zjit_diff stat keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Strip memory addresses (0x...) from stat keys so entries that differ only by object address (e.g. "##foo") are collapsed and their values summed for comparison. $ jq . data/output_272.json | grep -E Module.+object_id "not_inlined_cfuncs_##object_id": 26, "not_annotated_cfuncs_##object_id": 26, "ccall_##object_id": 26, "not_inlined_cfuncs_##object_id": 25, "not_annotated_cfuncs_##object_id": 25, "ccall_##object_id": 25, $ misc/zjit_diff.rb data/output_272.json -a | grep -E Module.+object_id ##object_id 26 → 25 ▼ -3.8% ##object_id 26 → 25 ▼ -3.8% ##object_id 26 → 25 ▼ -3.8% --- misc/zjit_diff.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/misc/zjit_diff.rb b/misc/zjit_diff.rb index eacbfc06..2971f0c1 100755 --- a/misc/zjit_diff.rb +++ b/misc/zjit_diff.rb @@ -84,6 +84,7 @@ def initialize(path, threshold_pct: DEFAULT_THRESHOLD_PCT, minimum_diff: DEFAULT @minimum_diff = minimum_diff @limit = limit @benchmark_filter = benchmarks + normalize_zjit_stats! end def run @@ -396,6 +397,28 @@ def format_bytes(bytes) "#{bytes}B" end end + + # Strip hex addresses from stat keys so that entries like + # "##foo" and "##foo" + # collapse into one. Numeric values are summed when keys merge. + def normalize_zjit_stats! + @raw_data.each_value do |benchmarks| + benchmarks.each_value do |bench_data| + next unless bench_data.is_a?(Hash) && bench_data['zjit_stats'].is_a?(Hash) + stats = bench_data['zjit_stats'] + normalized = {} + stats.each do |key, value| + nkey = key.gsub(/0x\h+/, '0x…') + if normalized.key?(nkey) && value.is_a?(Numeric) && normalized[nkey].is_a?(Numeric) + normalized[nkey] += value + else + normalized[nkey] = value + end + end + bench_data['zjit_stats'] = normalized + end + end + end end if __FILE__ == $0