Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion harness-ractor/harness.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions test/ractor_harness_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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
Loading