Skip to content

Commit 4fe1373

Browse files
hsbtclaude
andcommitted
Run knucleotide, gvl_release_acquire and railsbench on Windows
Windows has no fork, no /dev/zero and no shebang execution of bin/rails. knucleotide computes its workers sequentially there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 370f535 commit 4fe1373

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

‎benchmarks/gvl_release_acquire/benchmark.rb‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
require_relative "../../harness/loader"
22

3+
# Windows has no /dev/zero, so read the zeros from a file there.
4+
ZERO_PATH = if File.exist?("/dev/zero")
5+
"/dev/zero"
6+
else
7+
require "tmpdir"
8+
File.join(Dir.tmpdir, "ruby-bench-zero").tap do |path|
9+
File.binwrite(path, "\0" * 1_000_000) unless File.size?(path) == 1_000_000
10+
end
11+
end.freeze
12+
313
run_benchmark(5) do |num_rs, ractor_args|
4-
output = File.open("/dev/null", "wb")
5-
input = File.open("/dev/zero", "rb")
14+
output = File.open(File::NULL, "wb")
15+
input = File.open(ZERO_PATH, "rb")
616
100_000.times do
717
output.write(input.read(10))
818
end

‎benchmarks/knucleotide/benchmark.rb‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ def find_seq(seq, s)
3737

3838
class Worker
3939
def initialize(&block)
40+
# Platforms without fork (Windows) compute the result sequentially in this process,
41+
# so their timings are not comparable with the parallel ones.
42+
unless Process.respond_to?(:fork)
43+
@result = yield
44+
return
45+
end
46+
4047
@r, @w = IO.pipe
4148
@p = Process.fork do
4249
@r.close
@@ -47,6 +54,8 @@ def initialize(&block)
4754
end
4855

4956
def result
57+
return @result unless @p
58+
5059
ret = @r.read
5160
@r.close
5261
Process.wait(@p)

‎benchmarks/railsbench/benchmark.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# and this app's db/seeds.rb will delete and repopulate
99
# the database, so rows shouldn't accumulate.
1010
Dir.chdir __dir__
11-
use_gemfile extra_setup_cmd: "bin/rails db:migrate db:seed"
11+
use_gemfile extra_setup_cmd: "ruby bin/rails db:migrate db:seed" # Windows cannot run bin/rails by its shebang
1212

1313
require_relative 'config/environment'
1414

0 commit comments

Comments
 (0)