Project

General

Profile

Actions

Feature #16479

open

Let execution context local storage be backed by an ID table

Added by methodmissing (Lourens Naudé) about 4 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:96648]

Description

References https://github.com/ruby/ruby/pull/2814

Back fiber local variables with an ID table instead of st_table

lourens@CarbonX1:~/src/ruby/ruby$ make benchmark ITEM=fiber_locals COMPARE_RUBY="~/src/ruby/trunk/ruby" OPTS="--repeat-count 12 -v --repeat-result median"
/usr/local/bin/ruby --disable=gems -rrubygems -I./benchmark/lib ./benchmark/benchmark-driver/exe/benchmark-driver \
            --executables="compare-ruby::~/src/ruby/trunk/ruby -I.ext/common --disable-gem" \
            --executables="built-ruby::./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disable-gems --disable-gem" \
            $(find ./benchmark -maxdepth 1 -name 'fiber_locals' -o -name '*fiber_locals*.yml' -o -name '*fiber_locals*.rb' | sort) --repeat-count 12 -v --repeat-result median
compare-ruby: ruby 2.8.0dev (2020-01-03T05:53:25Z master 170f4dbb9b) [x86_64-linux]
built-ruby: ruby 2.8.0dev (2020-01-04T00:45:58Z ec-local-storage-i.. 333a5e8c7c) [x86_64-linux]
Calculating -------------------------------------
                     compare-ruby  built-ruby 
                key?      41.002M     46.144M i/s -      1.000M times in 0.024458s 0.021954s
                  []      37.590M     41.950M i/s -      1.000M times in 0.027206s 0.024386s
                keys      20.494M     19.289M i/s -      1.000M times in 0.049985s 0.057330s

Comparison:
                             key?
          built-ruby:  46144102.0 i/s 
        compare-ruby:  41001504.5 i/s - 1.13x  slower

                               []
          built-ruby:  41949873.8 i/s 
        compare-ruby:  37590350.2 i/s - 1.12x  slower

                             keys
        compare-ruby:  20494100.9 i/s 
          built-ruby:  19288690.6 i/s - 1.06x  slower

A regression on Thread#keys, however I think it's not the dominant use case, compared to key lookups.

Memory looks stable, and the difference within margin of error:

lourens@CarbonX1:~/src/ruby/ruby$ make benchmark ITEM=fiber_locals COMPARE_RUBY="~/src/ruby/trunk/ruby" OPTS="--repeat-count 12 -v -r memory"
/usr/local/bin/ruby --disable=gems -rrubygems -I./benchmark/lib ./benchmark/benchmark-driver/exe/benchmark-driver \
            --executables="compare-ruby::~/src/ruby/trunk/ruby -I.ext/common --disable-gem" \
            --executables="built-ruby::./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disable-gems --disable-gem" \
            $(find ./benchmark -maxdepth 1 -name 'fiber_locals' -o -name '*fiber_locals*.yml' -o -name '*fiber_locals*.rb' | sort) --repeat-count 12 -v -r memory
compare-ruby: ruby 2.8.0dev (2020-01-03T05:53:25Z master 170f4dbb9b) [x86_64-linux]
built-ruby: ruby 2.8.0dev (2020-01-04T00:45:58Z ec-local-storage-i.. 333a5e8c7c) [x86_64-linux]
Calculating -------------------------------------
                     compare-ruby  built-ruby 
                key?      19.768M     20.108M bytes -      1.000M times
                  []      19.888M     20.124M bytes -      1.000M times
                keys      19.852M     20.184M bytes -      1.000M times

Comparison:
                             key?
        compare-ruby:  19768000.0 bytes 
          built-ruby:  20108000.0 bytes - 1.02x  larger

                               []
        compare-ruby:  19888000.0 bytes 
          built-ruby:  20124000.0 bytes - 1.01x  larger

                             keys
        compare-ruby:  19852000.0 bytes 
          built-ruby:  20184000.0 bytes - 1.02x  larger

Thoughts?

No data to display

Actions

Also available in: Atom PDF

Like0