Skip to content

Commit bb92557

Browse files
committed
Define top-level #make_shareable to avoid defining Ractor
* Defining Ractor causes issues with gems assuming the rest of Ractor is available, like: lib/mri/psych.rb:709:in `config': undefined method `current' for class Ractor (NoMethodError)
1 parent 0e1ee81 commit bb92557

File tree

20 files changed

+36
-33
lines changed

20 files changed

+36
-33
lines changed

benchmarks-ractor/json_parse_float/benchmark.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
rand, rand, rand, rand, rand, rand, rand, rand, rand, rand,
1313
].to_json
1414
end
15-
Ractor.make_shareable(list)
15+
make_shareable(list)
1616

1717
# Work is divided between ractors
1818
run_benchmark(5, ractor_args: [list]) do |num_rs, list|

benchmarks-ractor/json_parse_string/benchmark.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"string #{i}" => "value #{i}",
3131
}.to_json
3232
end
33-
Ractor.make_shareable(list)
33+
make_shareable(list)
3434

3535
# Work is divided between ractors
3636
run_benchmark(5, ractor_args: [list]) do |num_rs, list|

benchmarks-ractor/knucleotide/benchmark.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def generate_test_sequence(size)
5252
end
5353

5454
# Make sequence shareable for Ractors
55-
TEST_SEQUENCE = Ractor.make_shareable(generate_test_sequence(100_000))
55+
TEST_SEQUENCE = make_shareable(generate_test_sequence(100_000))
5656

5757
run_benchmark(5) do |num_ractors, ractor_args|
5858
freqs = [1, 2]

benchmarks/attr_accessor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def get_value_loop
3535
end
3636

3737
OBJ = TheClass.new
38-
Ractor.make_shareable(OBJ)
38+
make_shareable(OBJ)
3939

4040
run_benchmark(10) do
4141
OBJ.get_value_loop

benchmarks/blurhash/benchmark.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def blurHashForPixels(xComponents, yComponents, width, height, rgb, bytesPerRow)
176176

177177
FILE = File.join(__dir__, "test.bin")
178178

179-
Ractor.make_shareable(ARRAY = File.read(FILE).bytes)
179+
make_shareable(ARRAY = File.read(FILE).bytes)
180180

181181
run_benchmark(10) do
182182
Blurhash.encode_rb(204, 204, ARRAY)

benchmarks/erubi/benchmark.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def run_erb
5858

5959
# This is taken from actual "gem server" data
6060
VALUES = JSON.load(File.read "gem_specs.json")
61-
Ractor.make_shareable(VALUES)
61+
make_shareable(VALUES)
6262
check_result_size(ErbRenderer.new(VALUES).run_erb)
6363

6464
run_benchmark(50) do

benchmarks/graphql/benchmark.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55

66
require "graphql"
77

8-
DATA = Ractor.make_shareable(File.read "negotiate.gql")
8+
DATA = make_shareable(File.read "negotiate.gql")
99

1010
if ENV["RUBY_BENCH_RACTOR_HARNESS"]
1111
GraphQL.default_parser
12-
Ractor.make_shareable(GraphQL::Tracing::NullTrace)
12+
make_shareable(GraphQL::Tracing::NullTrace)
1313
GraphQL::Language::Lexer.constants.each do |constant|
14-
Ractor.make_shareable(GraphQL::Language::Lexer.const_get(constant))
14+
make_shareable(GraphQL::Language::Lexer.const_get(constant))
1515
end
1616
GraphQL::Language::Parser.constants.each do |constant|
17-
Ractor.make_shareable(GraphQL::Language::Parser.const_get(constant))
17+
make_shareable(GraphQL::Language::Parser.const_get(constant))
1818
end
1919
end
2020

benchmarks/hexapdf/benchmark.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
Dir["/tmp/hexapdf-result*.pdf"].each { |file| FileUtils.rm file }
2020

2121
if ENV["RUBY_BENCH_RACTOR_HARNESS"]
22-
Ractor.make_shareable(HexaPDF::DefaultDocumentConfiguration)
23-
Ractor.make_shareable(HexaPDF::GlobalConfiguration)
22+
make_shareable(HexaPDF::DefaultDocumentConfiguration)
23+
make_shareable(HexaPDF::GlobalConfiguration)
2424
# TODO... still doesn't work
2525
end
2626

benchmarks/lee/benchmark.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ def lay(depth, solution)
8787
Dir.chdir __dir__
8888
use_gemfile
8989

90-
BOARD = Ractor.make_shareable(board)
91-
OBSTRUCTED = Ractor.make_shareable(obstructed)
92-
OUTPUT_FILENAME = Ractor.make_shareable(output_filename)
93-
EXPANSIONS_DIR = Ractor.make_shareable(expansions_dir)
90+
BOARD = make_shareable(board)
91+
OBSTRUCTED = make_shareable(obstructed)
92+
OUTPUT_FILENAME = make_shareable(output_filename)
93+
EXPANSIONS_DIR = make_shareable(expansions_dir)
9494

9595
run_benchmark(10) do
9696
depth = Lee::Matrix.new(BOARD.height, BOARD.width)

benchmarks/nbody/benchmark.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def offset_momentum(bodies)
134134
N = 20000
135135
NBODIES = BODIES.size
136136
if ENV["RUBY_BENCH_RACTOR_HARNESS"]
137-
Ractor.make_shareable(BODIES)
137+
make_shareable(BODIES)
138138
end
139139
DT = 0.01
140140

0 commit comments

Comments
 (0)