Skip to content

Commit fe13558

Browse files
committed
Get ractor-only benchmarks running with recent changes.
1 parent 82a1ea5 commit fe13558

File tree

10 files changed

+23
-35
lines changed

10 files changed

+23
-35
lines changed

benchmarks/ractor/gemfiles/Gemfile_json_parse.rb.lock

Lines changed: 0 additions & 13 deletions
This file was deleted.

benchmarks/ractor/gvl_release_acquire.rb renamed to benchmarks/ractor/gvl_release_acquire/benchmark.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require_relative "../../harness/loader"
1+
require_relative "../../../harness/loader"
22

33
run_benchmark(5) do |num_rs, ractor_args|
44
output = File.open("/dev/null", "wb")

benchmarks/ractor/json_parse_float.rb renamed to benchmarks/ractor/json_parse_float/benchmark.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
require_relative "../../harness/loader"
1+
require_relative "../../../harness/loader"
22

3-
use_ractor_gemfile("json_parse")
4-
puts "JSON #{JSON::VERSION}"
3+
Dir.chdir(__dir__)
4+
use_gemfile
5+
require "json"
6+
puts "json v#{JSON::VERSION}"
57

68
ELEMENTS = 100_000
7-
89
list = ELEMENTS.times.map do
910
{
1011
rand => rand,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gem "json", "2.13.2"

benchmarks/ractor/json_parse_string.rb renamed to benchmarks/ractor/json_parse_string/benchmark.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
require_relative "../../harness/loader"
1+
require_relative "../../../harness/loader"
22

3-
use_ractor_gemfile("json_parse")
4-
puts "JSON #{JSON::VERSION}"
3+
Dir.chdir(__dir__)
4+
use_gemfile
5+
require "json"
6+
puts "json v#{JSON::VERSION}"
57

68
ELEMENTS = 300_000
79
list = ELEMENTS.times.map do |i|

benchmarks/ractor/knucleotide.rb renamed to benchmarks/ractor/knucleotide/benchmark.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# k-nucleotide benchmark - Ractor implementation
55
# Mirrors the Process.fork version structure as closely as possible
66

7-
require_relative "../../harness/loader"
7+
require_relative "../../../harness/loader"
88

99
def frequency(seq, length)
1010
frequencies = Hash.new(0)

harness-ractor/harness.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
default_ractors = [
88
0, # without ractor
9-
1, 2, 4, 6, 8, 12, 16, 32
9+
1, 2, 4, 6, 8#, 12, 16, 32
1010
]
1111
if rs = ENV["YJIT_BENCH_RACTORS"]
1212
rs = rs.split(",").map(&:to_i) # If you want to include 0, you have to specify
@@ -31,6 +31,7 @@ def use_ractor_gemfile(filename)
3131
filename = File.expand_path("Gemfile_#{filename}.rb", "benchmarks/ractor/gemfiles")
3232
raise "Gemfile #{filename} doesn't exist" unless File.exist?(filename)
3333
use_inline_gemfile do
34+
gem "fiddle" # for maxrss
3435
instance_eval File.read(filename), filename, 1
3536
end
3637
end
@@ -70,7 +71,7 @@ def run_benchmark(num_itrs_hint, ractor_args: [], &block)
7071
else
7172
rs_list = []
7273
rs.times do
73-
rs_list << Ractor.new(*([rs] + ractor_args), &block)
74+
rs_list << Ractor.new(*([rs] + ractor_args), &block) # ractor_args are copied
7475
end
7576
while rs_list.any?
7677
r, _obj = Ractor.select(*rs_list)
@@ -88,6 +89,10 @@ def run_benchmark(num_itrs_hint, ractor_args: [], &block)
8889
return_results([], stats.values.flatten)
8990
end
9091

92+
# NOTE: we use `ractor_deep_dup` instead of `Ractor.make_shareable(copy: true)` for the case of
93+
# sending args to the block without a ractor because the arguments passed to `run_benchmark` are
94+
# sometimes modified, and we want to allow that because it improves compatibility. We don't want
95+
# it to be deeply frozen.
9196
def ractor_deep_dup(args)
9297
if Array === args
9398
ret = []

harness/harness-common.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,11 @@ def use_gemfile(extra_setup_cmd: nil)
4747
require "bundler"
4848
# Use Bundler.setup instead of require 'bundler/setup' to avoid bundler's autoswitch restarting the
4949
# process and messing with LOAD_PATH. Autoswitching occurs when the BUNDLED_WITH in the Gemfile.lock
50-
# is a different version than the loaded version of bundler.
50+
# is a different version than the loaded version of bundler. This can happen in development when
51+
# switching between ruby versions.
5152
Bundler.setup
5253
end
5354

54-
def use_inline_gemfile(&block)
55-
raise "Block must be given" unless block
56-
require "bundler/inline"
57-
gemfile(install=true) do
58-
source "https://rubygems.org"
59-
instance_eval(&block)
60-
end
61-
end
62-
6355
# This returns its best estimate of the Resident Set Size in bytes.
6456
# That's roughly the amount of memory the process takes, including shareable resources.
6557
# RSS reference: https://stackoverflow.com/questions/7880784/what-is-rss-and-vsz-in-linux-memory-management

run_benchmarks.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
260260

261261
bench_dir = "benchmarks"
262262

263-
if categories == ['ractor-only']
263+
if categories == ["ractor-only"]
264264
bench_dir = File.join(bench_dir, "ractor")
265265
harness = "harness-ractor"
266266
categories = []

0 commit comments

Comments
 (0)