Annotate Symbol#empty? as leaf#17464
Conversation
|
FWIW we can do better in ZJIT. Modified your script to print slightly differently. Can be done in a follow-up PR in a couple lines :) |
|
Can you name these PRs "Annotate XXX as leaf" going forward? "Rewrite in Ruby" is a misleading subject for this change. Until you stop using |
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.
39575de to
805ca07
Compare
|
@k0kubun @XrXr @tekknolagi @tekknolagi Interested to know what kind of a trick you used to get that kind of performance! 😁 |
Move
Symbol#empty?from the Csym_emptyintosymbol.rb, implemented asRBOOL(RSTRING_LEN(rb_sym2str(self)) == 0), mirroring the existing Symbol#to_s and #name leaf builtins.Also added an
annotate_builtin!inzjit/src/cruby_methods.rsto tell ZJIT that the method does not need GC now.Symbol#empty?as a leaf builtin, viabenchmark-driver(GC.disable,loop_count: 20_000_000, Apple M1). Speedup vs master (CFUNCsym_empty):--yjit--zjit:"".empty?:abcdefgh.empty?Windows native and WSL2 also get faster:
:"".empty?:abcdefgh.empty?WSL2 (Ubuntu)
x86_64-linux--yjit--zjit:"".empty?:abcdefgh.empty?