Skip to content

Commit 1474afd

Browse files
Microbenchmark for rb_sym2str under Ractors
1 parent 26bef91 commit 1474afd

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

benchmarks.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@ throw:
255255
#
256256
# Ractor scaling benchmarks
257257
#
258+
symbol-name-ractor:
259+
desc: repeatedly calls Symbol#name on a static symbol under the ractor harness to stress ID-to-string lookup.
260+
ractor: true
261+
ractor_only: true
262+
default_harness: harness-ractor
258263
gvl_release_acquire:
259264
desc: microbenchmark designed to test how fast the gvl can be acquired and released between ractors.
260265
ractor: true
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require_relative "../../harness/loader"
2+
3+
SYMBOL = :ruby_bench_id2str_pressure_static_symbol
4+
EXPECTED_NAME = SYMBOL.name
5+
ITERATIONS = Integer(ENV.fetch("SYMBOL_NAME_RACTOR_ITERS", 10_000_000))
6+
7+
run_benchmark(5) do |num_ractors = 0|
8+
iterations = num_ractors.zero? ? ITERATIONS : [ITERATIONS / num_ractors, 1].max
9+
10+
name = nil
11+
i = 0
12+
while i < iterations
13+
name = SYMBOL.name
14+
i += 1
15+
end
16+
17+
raise "unexpected Symbol#name result" unless name.equal?(EXPECTED_NAME)
18+
end

0 commit comments

Comments
 (0)