Files
ruby/benchmark/symbol_empty.yml
Sampo Kuokkanen 439c06b479 Annotate Symbol#empty? as leaf (#17464)
Move `Symbol#empty?` from the C `sym_empty` into `symbol.rb`, implemented as `RBOOL(RSTRING_LEN(rb_sym2str(self)) == 0)`, mirroring the existing Symbol#to_s and #name leaf builtins.

Also added an `annotate_builtin! ` in `zjit/src/cruby_methods.rs` to tell ZJIT that the method does not need GC now. 

`Symbol#empty?` as a leaf builtin, via `benchmark-driver` (`GC.disable`, `loop_count: 20_000_000`, Apple M1). Speedup vs master (CFUNC `sym_empty`):

| benchmark | interpreter | `--yjit` | `--zjit` |
|---|---:|---:|---:|
| `:"".empty?`       | **1.24x** | **1.30x** | **1.19x** |
| `:abcdefgh.empty?` | **1.19x** | **1.19x** | **1.17x** |

Windows native and WSL2 also get faster:

| benchmark | interpreter |
|---|---:|
| `:"".empty?`       | **1.47x** |
| `:abcdefgh.empty?` | **1.36x** |

### WSL2 (Ubuntu) `x86_64-linux`

| benchmark | interpreter | `--yjit` | `--zjit` |
|---|---:|---:|---:|
| `:"".empty?`       | **1.39x** | **1.33x** | **1.32x** |
| `:abcdefgh.empty?` | **1.37x** | **1.39x** | **1.33x** |
2026-07-02 04:26:34 +00:00

9 lines
152 B
YAML

prelude: |
sym0 = :""
sym8 = :abcdefgh
GC.disable
benchmark:
symbol_empty-0: sym0.empty?
symbol_empty-8: sym8.empty?
loop_count: 20000000