From: eregontp@... Date: 2016-04-13T09:32:14+00:00 Subject: [ruby-core:74929] [Ruby trunk Bug#12274] accessing to instance variable should be fast. Issue #12274 has been updated by Benoit Daloze. Masaya Tarui wrote: > there are 2 parts of optimization. > > * share inline cache between same symbol(at compile.c) > > * inline fast pass only and cut useless check(RB_TYPE_P).(at insns.def) > > We can skip st_lookup from the 2nd insns by sharing cache. > > Inlining register pass may have a bit penalty. > > Cutting check was a accidental :-), but it is not necessary if cached serial equals class one. I see, thanks for explaining :) About the object check, is it not problematic to do ((struct RBasic*)obj)->klass if obj is a tagged integer (since klass is the second member, after flags)? Or is there a hidden check before doing that? ---------------------------------------- Bug #12274: accessing to instance variable should be fast. https://bugs.ruby-lang.org/issues/12274#change-58058 * Author: Masaya Tarui * Status: Open * Priority: Normal * Assignee: * ruby -v: ruby 2.4.0dev (2016-04-12 trunk 54553) [x86_64-linux] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- Currently, accessing to instance variable is quite slower than accessing to local variable. I think accessing to instance variable is basic operation and it should be fast, so tried to improve. patch: https://github.com/tarui/ruby/commit/dd993da80c7ad84340689137bf8b308793595cae On mame's optcarrot benchmark, (https://github.com/mame/optcarrot/) it is 10%(!) faster than trunk. It increases in the maintenance cost a little, but can I commit it? ``` $ ./ruby -v --disable-gems ../../optcarrot/bin/optcarrot --benchmark ../../optcarrot/examples/Lan_Master.nes ruby 2.4.0dev (2016-04-12 trunk 54553) [x86_64-linux] fps: 13.664029283085743 checksum: 59662 $ ./ruby -v --disable-gems ../../optcarrot/bin/optcarrot --benchmark ../../optcarrot/examples/Lan_Master.nes ruby 2.4.0dev (2016-04-12 fast-ivar-access 54553) [x86_64-linux] fps: 15.120651593726231 checksum: 59662 -- https://bugs.ruby-lang.org/ Unsubscribe: