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
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ruby, head, truffleruby]
ruby: [ruby, head]
if: ${{ github.event_name != 'schedule' || github.repository == 'ruby/ruby-bench' }}
steps:
- uses: actions/checkout@v3
Expand All @@ -66,14 +66,13 @@ jobs:
WARMUP_ITRS: '1'
MIN_BENCH_ITRS: '1'
MIN_BENCH_TIME: '0'
continue-on-error: ${{ matrix.ruby == 'truffleruby' }}

benchmark-ractor-only:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: [ruby, head, truffleruby]
ruby: [ruby, head]
if: ${{ github.event_name != 'schedule' || github.repository == 'ruby/ruby-bench' }}
steps:
- uses: actions/checkout@v3
Expand All @@ -88,7 +87,6 @@ jobs:
WARMUP_ITRS: '1'
MIN_BENCH_ITRS: '1'
MIN_BENCH_TIME: '0'
continue-on-error: ${{ matrix.ruby == 'truffleruby' }}

benchmark-graph:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion benchmarks-ractor/json_parse_float/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
rand, rand, rand, rand, rand, rand, rand, rand, rand, rand,
].to_json
end
Ractor.make_shareable(list)
make_shareable(list)

# Work is divided between ractors
run_benchmark(5, ractor_args: [list]) do |num_rs, list|
Expand Down
2 changes: 1 addition & 1 deletion benchmarks-ractor/json_parse_string/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"string #{i}" => "value #{i}",
}.to_json
end
Ractor.make_shareable(list)
make_shareable(list)

# Work is divided between ractors
run_benchmark(5, ractor_args: [list]) do |num_rs, list|
Expand Down
2 changes: 1 addition & 1 deletion benchmarks-ractor/knucleotide/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def generate_test_sequence(size)
end

# Make sequence shareable for Ractors
TEST_SEQUENCE = Ractor.make_shareable(generate_test_sequence(100_000))
TEST_SEQUENCE = make_shareable(generate_test_sequence(100_000))

run_benchmark(5) do |num_ractors, ractor_args|
freqs = [1, 2]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/attr_accessor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_value_loop
end

OBJ = TheClass.new
Ractor.make_shareable(OBJ)
make_shareable(OBJ)

run_benchmark(10) do
OBJ.get_value_loop
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/blurhash/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def blurHashForPixels(xComponents, yComponents, width, height, rgb, bytesPerRow)

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

Ractor.make_shareable(ARRAY = File.read(FILE).bytes)
make_shareable(ARRAY = File.read(FILE).bytes)

run_benchmark(10) do
Blurhash.encode_rb(204, 204, ARRAY)
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/erubi/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def run_erb

# This is taken from actual "gem server" data
VALUES = JSON.load(File.read "gem_specs.json")
Ractor.make_shareable(VALUES)
make_shareable(VALUES)
check_result_size(ErbRenderer.new(VALUES).run_erb)

run_benchmark(50) do
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/graphql/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

require "graphql"

DATA = Ractor.make_shareable(File.read "negotiate.gql")
DATA = make_shareable(File.read "negotiate.gql")

if ENV["RUBY_BENCH_RACTOR_HARNESS"]
GraphQL.default_parser
Ractor.make_shareable(GraphQL::Tracing::NullTrace)
make_shareable(GraphQL::Tracing::NullTrace)
GraphQL::Language::Lexer.constants.each do |constant|
Ractor.make_shareable(GraphQL::Language::Lexer.const_get(constant))
make_shareable(GraphQL::Language::Lexer.const_get(constant))
end
GraphQL::Language::Parser.constants.each do |constant|
Ractor.make_shareable(GraphQL::Language::Parser.const_get(constant))
make_shareable(GraphQL::Language::Parser.const_get(constant))
end
end

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/hexapdf/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
Dir["/tmp/hexapdf-result*.pdf"].each { |file| FileUtils.rm file }

if ENV["RUBY_BENCH_RACTOR_HARNESS"]
Ractor.make_shareable(HexaPDF::DefaultDocumentConfiguration)
Ractor.make_shareable(HexaPDF::GlobalConfiguration)
make_shareable(HexaPDF::DefaultDocumentConfiguration)
make_shareable(HexaPDF::GlobalConfiguration)
# TODO... still doesn't work
end

Expand Down
8 changes: 4 additions & 4 deletions benchmarks/lee/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ def lay(depth, solution)
Dir.chdir __dir__
use_gemfile

BOARD = Ractor.make_shareable(board)
OBSTRUCTED = Ractor.make_shareable(obstructed)
OUTPUT_FILENAME = Ractor.make_shareable(output_filename)
EXPANSIONS_DIR = Ractor.make_shareable(expansions_dir)
BOARD = make_shareable(board)
OBSTRUCTED = make_shareable(obstructed)
OUTPUT_FILENAME = make_shareable(output_filename)
EXPANSIONS_DIR = make_shareable(expansions_dir)

run_benchmark(10) do
depth = Lee::Matrix.new(BOARD.height, BOARD.width)
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/nbody/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def offset_momentum(bodies)
N = 20000
NBODIES = BODIES.size
if ENV["RUBY_BENCH_RACTOR_HARNESS"]
Ractor.make_shareable(BODIES)
make_shareable(BODIES)
end
DT = 0.01

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/optcarrot/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
Optcarrot::PPU::NMT_TABLE,
Optcarrot::CPU::DISPATCH,
Optcarrot::ROM::MAPPER_DB,
].each { |const| Ractor.make_shareable(const) }
].each { |const| make_shareable(const) }

ROM_PATH = File.join(__dir__, "examples/Lan_Master.nes").freeze
ENV["WARMUP_ITRS"] = "1"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/protoboeuf-encode/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Dir.chdir __dir__
fake_msg_bins = Marshal.load(File.binread('encoded_msgs.bin'))
LOTS = Ractor.make_shareable(fake_msg_bins.map { |bin| ProtoBoeuf::ParkingLot.decode bin })
LOTS = make_shareable(fake_msg_bins.map { |bin| ProtoBoeuf::ParkingLot.decode bin })

run_benchmark(20) do
LOTS.each { |lot| ProtoBoeuf::ParkingLot.encode lot }
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/protoboeuf/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require_relative 'benchmark_pb'

Dir.chdir __dir__
FAKE_MSG_BINS = Ractor.make_shareable(Marshal.load(File.binread('encoded_msgs.bin')))
FAKE_MSG_BINS = make_shareable(Marshal.load(File.binread('encoded_msgs.bin')))

run_benchmark(20) do
FAKE_MSG_BINS.each { |bin| ProtoBoeuf::ParkingLot.decode bin }
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/psych-load/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
raise "Not loading any YAML files!"
end

TEST_YAML = Ractor.make_shareable(test_yaml_files.map { |p| File.read(p) })
TEST_YAML = make_shareable(test_yaml_files.map { |p| File.read(p) })

run_benchmark(10) do
test_yaml = TEST_YAML
Expand Down
Empty file removed benchmarks/railsbench/vendor/.keep
Empty file.
2 changes: 1 addition & 1 deletion benchmarks/ruby-json/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,6 @@ def parse_item

# Public domain football data taken from:
# https://github.com/openfootball/football.json/blob/master/2011-12/at.1.json
SOURCE = Ractor.make_shareable(IO.read("#{__dir__}/data.json"))
SOURCE = make_shareable(IO.read("#{__dir__}/data.json"))

run_benchmark(10) { source = SOURCE; 100.times { JSONParser.new(source).parse } }
4 changes: 2 additions & 2 deletions benchmarks/ruby-lsp/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
require "ruby_lsp/internal"

path = File.expand_path("fixture.rb", __dir__)
INDEX_PATH = Ractor.make_shareable(RubyIndexer::IndexablePath.new(File.expand_path("../..", __dir__), path))
CONTENT = Ractor.make_shareable(File.read(path))
INDEX_PATH = make_shareable(RubyIndexer::IndexablePath.new(File.expand_path("../..", __dir__), path))
CONTENT = make_shareable(File.read(path))

run_benchmark(200) do
RubyIndexer::Index.new.index_single(INDEX_PATH, CONTENT)
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/rubyboy/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# needing to re-initialize but not sure how to determine that.
COUNT = 500

Ractor.make_shareable(Rubyboy::ApuChannels::Channel1::WAVE_DUTY)
Ractor.make_shareable(Rubyboy::ApuChannels::Channel2::WAVE_DUTY)
make_shareable(Rubyboy::ApuChannels::Channel1::WAVE_DUTY)
make_shareable(Rubyboy::ApuChannels::Channel2::WAVE_DUTY)

run_benchmark(200) do
# Results are much more consistent if we re-initialize each time.
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/sudoku.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def sd_solve(mr, mc, s)
end
end

HARD20 = Ractor.make_shareable([
HARD20 = make_shareable([
"..............3.85..1.2.......5.7.....4...1...9.......5......73..2.1........4...9",
".......12........3..23..4....18....5.6..7.8.......9.....85.....9...4.5..47...6...",
".2..5.7..4..1....68....3...2....8..3.4..2.5.....6...1...2.9.....9......57.4...9..",
Expand All @@ -212,8 +212,8 @@ def sd_solve(mr, mc, s)
])

MR, MC = sd_genmat
Ractor.make_shareable(MR)
Ractor.make_shareable(MC)
make_shareable(MR)
make_shareable(MC)

run_benchmark(20) do
mr = MR
Expand Down
11 changes: 7 additions & 4 deletions harness/harness-common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
# Seed the global random number generator for repeatability between runs
Random.srand(1337)

if !Ractor.respond_to?(:make_shareable)
class Ractor
#noop
def make_shareable(obj, copy: false); obj; end
if defined?(Ractor.make_shareable)
def make_shareable(obj, copy: false)
Ractor.make_shareable(obj, copy: copy)
end
else
def make_shareable(obj, copy: false)
obj # noop
end
end

Expand Down
Loading