Skip to content

Print GC harness averages without truncating them - #570

Open
thomasklemm wants to merge 1 commit into
ruby:mainfrom
thomasklemm:thomasklemm/gc-harness-average-precision
Open

thomasklemm wants to merge 1 commit into
ruby:mainfrom
thomasklemm:thomasklemm/gc-harness-average-precision

Conversation

@thomasklemm

Copy link
Copy Markdown
Contributor

The "Average marking time" and "Average sweeping time" lines that --harness=gc prints are rounded down to whole milliseconds. GC.stat(:marking_time) and GC.stat(:sweeping_time) count whole milliseconds, so each iteration's value is an Integer, and harness/gc.rb divided their sum with Integer division. For example, three iterations that mark 1, 0 and 0 ms print 0.0ms instead of 0.3ms. The error of up to 1 ms matters when marking takes a few milliseconds per iteration, as on railsbench with ZJIT (eight minor GCs of about 0.35 ms each). This uses fdiv. The results JSON and the summary tables don't go through these two lines, so nothing else changes.

The new test runs the harness with stubbed GC samples and fails on main. I found this while measuring GC time for ruby/ruby#19685, alongside XrXr's #562 (timings without GC time) and eightbitraptor's #541 (GC per ruby table).

GC.stat reports marking_time and sweeping_time in whole milliseconds, so
the per-iteration deltas are Integers and the printed averages used
Integer division. The JSON results are not affected.
@thomasklemm
thomasklemm marked this pull request as ready for review November 5, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant