Skip to content

Commit fe53533

Browse files
Force a major GC and compact before measuring RSS
This will hopefully remove any variance caused by one benchmark run having just hit a GC and one not.
1 parent c64ac86 commit fe53533

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

harness/harness-common.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ def return_results(warmup_iterations, bench_iterations)
146146
yjit_stats = RubyVM::YJIT.runtime_stats if defined?(RubyVM::YJIT.enabled?) && RubyVM::YJIT.enabled?
147147
zjit_stats = RubyVM::ZJIT.stats if defined?(RubyVM::ZJIT.enabled?) && RubyVM::ZJIT.enabled?
148148

149-
# Collect our own peak mem usage as soon as reasonable after finishing the last iteration.
149+
# Full GC then compact before measuring RSS so fragmentation doesn't inflate the number.
150+
GC.start(full_mark: true, immediate_sweep: true)
151+
GC.compact if GC.respond_to?(:compact)
152+
150153
rss = get_rss
151154
ruby_bench_results["rss"] = rss
152155
if maxrss = get_maxrss

0 commit comments

Comments
 (0)