Skip to content

Commit

Permalink
YJIT: Fix edge and total counts in exit_locations (#7702)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
jhawthorn committed Apr 13, 2023
1 parent bbe69fb commit acc5c74
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions yjit.rb
Expand Up @@ -70,6 +70,8 @@ def self.exit_locations
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
Expand All @@ -78,14 +80,14 @@ def self.exit_locations
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
Expand All @@ -95,8 +97,6 @@ def self.exit_locations
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]
Expand Down

0 comments on commit acc5c74

Please sign in to comment.