File tree Expand file tree Collapse file tree 6 files changed +30
-14
lines changed
Expand file tree Collapse file tree 6 files changed +30
-14
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ etanni:
6060 desc : etanni is an older, extremely simple template-lang format that basically turns your template into an "eval" with a lot of heredocs.
6161fannkuchredux :
6262 desc : fannkuchredux from the Computer Language Benchmarks Game.
63+ ractor : true
6364fluentd :
6465 desc : fluentd is a log collector, which parses logs in a server and forwards them to various destinations.
6566graphql :
@@ -81,8 +82,10 @@ ruby-json:
8182 ractor : true
8283rubyboy :
8384 desc : Rubyboy is a functional headless GameBoy emulator, run on a specific game cartridge for a specific number of frames.
85+ ractor : true
8486rubykon :
8587 desc : Ruby solver for Go (the boardgame.) Runs many iterations forward from an initial starting board.
88+ ractor : true
8689tinygql :
8790 desc : TinyGQL gem parsing a large file in pure Ruby
8891nqueens :
@@ -99,8 +102,10 @@ blurhash:
99102 ractor : true
100103protoboeuf :
101104 desc : protoboeuf (pure-Ruby protobuf) message decoding
105+ ractor : true
102106protoboeuf-encode :
103107 desc : protoboeuf (pure-Ruby protobuf) message encoding
108+ ractor : true
104109
105110#
106111# MicroBenchmarks
Original file line number Diff line number Diff line change @@ -54,12 +54,12 @@ def fannkuch(n)
5454end
5555
5656#n = (ARGV[0] || 1).to_i
57- n = 9 # Benchmarks Game uses n = 12, but it's too slow
57+ N = 9 # Benchmarks Game uses n = 12, but it's too slow
5858
5959require_relative '../../harness/loader'
6060
6161run_benchmark ( 10 ) do
62- sum , flips = fannkuch ( n )
62+ sum , flips = fannkuch ( N )
6363
6464 if sum != 8629
6565 raise RuntimeError , "incorrect sum: #{ sum } "
Original file line number Diff line number Diff line change 55
66Dir . chdir __dir__
77fake_msg_bins = Marshal . load ( File . binread ( 'encoded_msgs.bin' ) )
8- lots = fake_msg_bins . map { |bin | ProtoBoeuf ::ParkingLot . decode bin }
8+ LOTS = Ractor . make_shareable ( fake_msg_bins . map { |bin | ProtoBoeuf ::ParkingLot . decode bin } )
99
1010run_benchmark ( 20 ) do
11- lots . each { |lot | ProtoBoeuf ::ParkingLot . encode lot }
11+ LOTS . each { |lot | ProtoBoeuf ::ParkingLot . encode lot }
1212end
Original file line number Diff line number Diff line change 44require_relative 'benchmark_pb'
55
66Dir . chdir __dir__
7- fake_msg_bins = Marshal . load ( File . binread ( 'encoded_msgs.bin' ) )
7+ FAKE_MSG_BINS = Ractor . make_shareable ( Marshal . load ( File . binread ( 'encoded_msgs.bin' ) ) )
88
99run_benchmark ( 20 ) do
10- fake_msg_bins . each { |bin | ProtoBoeuf ::ParkingLot . decode bin }
10+ FAKE_MSG_BINS . each { |bin | ProtoBoeuf ::ParkingLot . decode bin }
1111end
Original file line number Diff line number Diff line change 1111require 'rubyboy/emulator_headless'
1212
1313# The rom is included in the gem in a sibling directory to the rubyboy code.
14- rom_path = File . expand_path ( "../../roms/tobu.gb" , $". detect { |x | x . end_with? ( "/rubyboy/emulator_headless.rb" ) } )
14+ ROM_PATH = File . expand_path ( "../../roms/tobu.gb" , $". detect { |x | x . end_with? ( "/rubyboy/emulator_headless.rb" ) } ) . freeze
1515
1616# A count of 500 produces results similar to our optcarrot benchmark.
1717# It's possible there is a number that produces a consistent benchmark without
1818# needing to re-initialize but not sure how to determine that.
19- count = 500
19+ COUNT = 500
20+
21+ Ractor . make_shareable ( Rubyboy ::ApuChannels ::Channel1 ::WAVE_DUTY )
22+ Ractor . make_shareable ( Rubyboy ::ApuChannels ::Channel2 ::WAVE_DUTY )
2023
2124run_benchmark ( 200 ) do
2225 # Results are much more consistent if we re-initialize each time.
2326 # Reusing the same eumlator increases stddev by 65x.
24- emulator = Rubyboy ::EmulatorHeadless . new ( rom_path )
25- count . times do
27+ emulator = Rubyboy ::EmulatorHeadless . new ( ROM_PATH )
28+ COUNT . times do
2629 emulator . step
2730 end
2831end
Original file line number Diff line number Diff line change 1010# return the same stable best_move, even for identical initial board state and number of iterations.
1111
1212ITERATIONS = 100
13- game_state = Rubykon ::GameState . new Rubykon ::Game . new ( 19 )
14- mcts = MCTS ::MCTS . new
1513
16- run_benchmark ( 10 ) do
17- mcts . start game_state , ITERATIONS
14+ if ENV [ "YJIT_BENCH_RACTOR_HARNESS" ]
15+ run_benchmark ( 10 ) do
16+ state = Rubykon ::GameState . new Rubykon ::Game . new ( 19 )
17+ m = MCTS ::MCTS . new
18+ m . start state , ITERATIONS
19+ end
20+ else
21+ game_state = Rubykon ::GameState . new Rubykon ::Game . new ( 19 )
22+ mcts = MCTS ::MCTS . new
23+ run_benchmark ( 10 ) do
24+ mcts . start game_state , ITERATIONS
25+ end
1826end
You can’t perform that action at this time.
0 commit comments