Skip to content

Commit 1eb06e4

Browse files
hsbtclaude
andcommitted
Read zeros from a file in gvl_release_acquire on Windows
Windows has no /dev/zero. The benchmark is about GVL handoffs rather than I/O, so a regular file of the same zeros is enough, and it is kept in the ignored data/ directory rather than left in a temporary directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 5b0ff24 commit 1eb06e4

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎benchmarks/gvl_release_acquire/benchmark.rb‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
require_relative "../../harness/loader"
22

3+
# Windows has no /dev/zero, so read the same zeros from a regular file kept in data/.
4+
ZERO_PATH = if File.exist?("/dev/zero")
5+
"/dev/zero"
6+
else
7+
File.join(__dir__, "data", "zero").tap do |path|
8+
unless File.size?(path) == 1_000_000
9+
Dir.mkdir(File.dirname(path)) unless Dir.exist?(File.dirname(path))
10+
File.binwrite(path, "\0" * 1_000_000)
11+
end
12+
end
13+
end.freeze
14+
315
run_benchmark(5) do |num_rs, ractor_args|
416
output = File.open(File::NULL, "wb")
5-
input = File.open("/dev/zero", "rb")
17+
input = File.open(ZERO_PATH, "rb")
618
100_000.times do
719
output.write(input.read(10))
820
end

0 commit comments

Comments
 (0)