From acc5c746482218ed51e602af88bb5c48f8d557d5 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Thu, 13 Apr 2023 11:37:37 -0700 Subject: [PATCH] YJIT: Fix edge and total counts in exit_locations (#7702) The stackprof-format raw samples are suffixed with a count (ie. how many times did the previously recorded side-exit repeat). Previously we were correctly using this value to increment the :samples count, but not the :total_samples count or edges. This made the stackprof aggregate results incorrect (though any flamegraphs generated should have been correct, since those only rely on raw samples). --- yjit.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/yjit.rb b/yjit.rb index 1c4d77e833..f351f2b6ca 100644 --- a/yjit.rb +++ b/yjit.rb @@ -70,6 +70,8 @@ module RubyVM::YJIT stack_length = raw_samples[i] + 1 i += 1 # consume the stack length + sample_count = raw_samples[i + stack_length] + prev_frame_id = nil stack_length.times do |idx| idx += i @@ -78,14 +80,14 @@ module RubyVM::YJIT if prev_frame_id prev_frame = frames[prev_frame_id] prev_frame[:edges][frame_id] ||= 0 - prev_frame[:edges][frame_id] += 1 + prev_frame[:edges][frame_id] += sample_count end frame_info = frames[frame_id] - frame_info[:total_samples] += 1 + frame_info[:total_samples] += sample_count frame_info[:lines][line_samples[idx]] ||= [0, 0] - frame_info[:lines][line_samples[idx]][0] += 1 + frame_info[:lines][line_samples[idx]][0] += sample_count prev_frame_id = frame_id end @@ -95,8 +97,6 @@ module RubyVM::YJIT top_frame_id = prev_frame_id top_frame_line = 1 - sample_count = raw_samples[i] - frames[top_frame_id][:samples] += sample_count frames[top_frame_id][:lines] ||= {} frames[top_frame_id][:lines][top_frame_line] ||= [0, 0]