diff options
author | Aaron Patterson <tenderlove@ruby-lang.org> | 2021-02-22 16:18:10 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2021-05-03 14:11:48 -0700 |
commit | 9a6226c61ea8a8ae7b3516b693a0d6e73526a99f (patch) | |
tree | 7cb87204a9fd0acc988a0eb84f05eb0a526aad2b /benchmark | |
parent | a6ff1dc6f98b29661fd1147d84bc3b928bed618f (diff) |
Eagerly allocate instance variable tables along with object
This allows us to allocate the right size for the object in advance,
meaning that we don't have to pay the cost of ivar table extension
later. The idea is that if an object type ever became "extended" at
some point, then it is very likely it will become extended again. So we
may as well allocate the ivar table up front.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4216
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/ivar_extend.yml | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/benchmark/ivar_extend.yml b/benchmark/ivar_extend.yml new file mode 100644 index 0000000000..eb9ee923f5 --- /dev/null +++ b/benchmark/ivar_extend.yml @@ -0,0 +1,23 @@ +prelude: | + class Embedded + def initialize + @a = 1 + @b = 1 + @c = 1 + end + end + + class Extended + def initialize + @a = 1 + @b = 1 + @c = 1 + @d = 1 + @e = 1 + @f = 1 + end + end +benchmark: + embedded: Embedded.new + extended: Extended.new +loop_count: 20_000_000 |