You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement unboxed_ary to avoid repeated access to packed data
Ruby objects use a lot of bit packing to save on memory, and also
have multiple layouts, it's particularly true for Arrays which can be
embedded, heap allocated, or shared.
This saves memory, but can cause a lot of execution overhead when
the same piece of information is packed and unpacked many times.
Instead if we primarily work with a "normalized" representation
of the object, that we keep in sync with the actual RArray, we
can save quite a bit of overhead as showcase in the benchmark.
Of course applying this to more than a couple functions is a lot
of work and it's unclear whether it's worth it or not.
```
$ make -j benchmark ITEM="rb_ary_push" BUILT_RUBY="./miniruby" COMPARE_RUBY="./miniruby-baseline"
/opt/rubies/3.3.4/bin/ruby --disable=gems -rrubygems -I../benchmark/lib ../benchmark/benchmark-driver/exe/benchmark-driver \
--executables="compare-ruby::./miniruby-baseline -I.ext/common --disable-gem" \
--executables="built-ruby::./miniruby -I../lib -I. -I.ext/common ../tool/runruby.rb --extout=.ext -- --disable-gems --disable-gem" \
--output=markdown --output-compare -v $(find ../benchmark -maxdepth 1 -name 'rb_ary_push' -o -name '*rb_ary_push*.yml' -o -name '*rb_ary_push*.rb' | sort)
compare-ruby: ruby 3.4.0dev (2024-12-05T19:11:39Z ary-batch-info e9407cf) +PRISM [arm64-darwin23]
built-ruby: ruby 3.4.0dev (2024-12-05T19:11:39Z ary-batch-info 46757e76db) +PRISM [arm64-darwin23]
warming up..
| |compare-ruby|built-ruby|
|:-------|-----------:|---------:|
|64*2k | 848.804| 1.151k|
| | -| 1.36x|
|128*1k | 1.651k| 2.217k|
| | -| 1.34x|
```
0 commit comments