diff --git a/harness-ractor/harness.rb b/harness-ractor/harness.rb index cf24076a..a5d2d4b2 100644 --- a/harness-ractor/harness.rb +++ b/harness-ractor/harness.rb @@ -36,7 +36,6 @@ def join SETTLE_SLEEP = Float(ENV.fetch("RACTOR_MEM_SETTLE_SLEEP", 0.1)) PEAK_SAMPLE_INTERVAL = Float(ENV.fetch("RACTOR_MEM_PEAK_SAMPLE_INTERVAL", 0.005)) GLOBAL_GC_START = GC.method(:start).parameters.include?([:key, :global]) -PAGE_SIZE = Etc.sysconf(Etc::SC_PAGESIZE) def run_benchmark(num_itrs_hint, ractor_args: [], scenario: false, &block) warmup_itrs = Integer(ENV.fetch('WARMUP_ITRS', 5)) @@ -375,6 +374,7 @@ def gc_settle STATM_FILE = "/proc/self/statm" STATM_AVAILABLE = File.exist?(STATM_FILE) +PAGE_SIZE = Etc.sysconf(Etc::SC_PAGESIZE) if STATM_AVAILABLE # The resident set size right now. /proc/self/statm is the cheapest source, which # matters because the peak sampler reads it every PEAK_SAMPLE_INTERVAL. Off Linux diff --git a/test/ractor_harness_test.rb b/test/ractor_harness_test.rb index e68bc7de..cab55a44 100644 --- a/test/ractor_harness_test.rb +++ b/test/ractor_harness_test.rb @@ -9,12 +9,13 @@ root = File.expand_path('..', __dir__) Dir.mktmpdir do |dir| result_path = File.join(dir, 'results.json') - calls_path = File.join(dir, 'calls.txt') + calls_dir = File.join(dir, 'calls') + Dir.mkdir(calls_dir) script = File.join(dir, 'workload.rb') File.write(script, <<~RUBY) require #{File.join(root, 'harness', 'loader').inspect} run_benchmark(1) do |count| - File.open(#{calls_path.inspect}, 'a') { |f| f.puts(count) } + File.open(File.join(#{calls_dir.inspect}, Ractor.current.object_id.to_s), 'a') { |f| f.puts(count) } end RUBY env = { @@ -34,7 +35,8 @@ assert_equal({ '2' => 2 }, data['warmup_by_ractors'].transform_values(&:size)) assert_equal({ '2' => 1 }, data['bench_by_ractors'].transform_values(&:size)) assert_equal data['warmup_by_ractors']['2'], data['warmup'] - assert_equal ['2'] * 6, File.readlines(calls_path, chomp: true), '(2 warmup + 1 measured) iterations x 2 Ractors' + calls = Dir.children(calls_dir).flat_map { |f| File.readlines(File.join(calls_dir, f), chomp: true) } + assert_equal ['2'] * 6, calls, '(2 warmup + 1 measured) iterations x 2 Ractors' end end end