summaryrefslogtreecommitdiff
path: root/yjit.rb
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2023-04-13 11:37:37 -0700
committerGitHub <noreply@github.com>2023-04-13 14:37:37 -0400
commitacc5c746482218ed51e602af88bb5c48f8d557d5 (patch)
tree14b3b8717ac9a6c8a0620631d855d1ad96c744a6 /yjit.rb
parentbbe69fba595433d0a7d684b70c0117f49cecadb2 (diff)
downloadruby-acc5c746482218ed51e602af88bb5c48f8d557d5.tar.gz
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).
Diffstat (limited to 'yjit.rb')
-rw-r--r--yjit.rb10
1 files 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]