Skip to content

Commit 60d93c0

Browse files
Merge pull request #481 from ruby/mvh-compact-rss
Force a major GC and compact before measuring RSS
2 parents c64ac86 + fe53533 commit 60d93c0

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)