From ded078c2c44e5a1f9f4191a7021cfe394ac93ba2 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Tue, 8 Oct 2024 11:44:59 -0400 Subject: YJIT: Fastpath for Module#name (#11819) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Module#name shows up as a top C method callee in lobsters so probably common enough. It's also easy to substitute thanks to rb_mod_name() already having no GC yield points. klass = BasicObject 50_000_000.times { klass.name } Benchmark 1: /.rubies/post/bin/ruby --yjit mod_name.rb Time (mean ± σ): 1.433 s ± 0.010 s [User: 1.410 s, System: 0.010 s] Range (min … max): 1.421 s … 1.449 s 10 runs Benchmark 2: /.rubies/mstr/bin/ruby --yjit mod_name.rb Time (mean ± σ): 1.491 s ± 0.012 s [User: 1.468 s, System: 0.010 s] Range (min … max): 1.470 s … 1.511 s 10 runs Summary /.rubies/post/bin/ruby --yjit mod_name.rb ran 1.04 ± 0.01 times faster than /.rubies/mstr/bin/ruby --yjit mod_name.rb --- yjit/bindgen/src/main.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'yjit/bindgen') diff --git a/yjit/bindgen/src/main.rs b/yjit/bindgen/src/main.rs index ea60dd23b9..28e7ac3e9c 100644 --- a/yjit/bindgen/src/main.rs +++ b/yjit/bindgen/src/main.rs @@ -378,6 +378,7 @@ fn main() { .allowlist_function("rb_attr_get") .allowlist_function("rb_ivar_defined") .allowlist_function("rb_ivar_get") + .allowlist_function("rb_mod_name") // From internal/vm.h .allowlist_var("rb_vm_insns_count") -- cgit v1.2.3