Issue #16479 has been reported by methodmissing (Lourens Naud=E9).

----------------------------------------
Feature #16479: Let execution context local storage be backed by an ID table
https://bugs.ruby-lang.org/issues/16479

* Author: methodmissing (Lourens Naud=E9)
* Status: Open
* Priority: Normal
* Assignee: =

* Target version: =

----------------------------------------
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=3Dfiber_locals COMPAR=
E_RUBY=3D"~/src/ruby/trunk/ruby" OPTS=3D"--repeat-count 12 -v --repeat-resu=
lt median"
/usr/local/bin/ruby --disable=3Dgems -rrubygems -I./benchmark/lib ./benchma=
rk/benchmark-driver/exe/benchmark-driver \
            --executables=3D"compare-ruby::~/src/ruby/trunk/ruby -I.ext/com=
mon --disable-gem" \
            --executables=3D"built-ruby::./miniruby -I./lib -I. -I.ext/comm=
on  ./tool/runruby.rb --extout=3D.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_6=
4-linux]
built-ruby: ruby 2.8.0dev (2020-01-04T00:45:58Z ec-local-storage-i.. 333a5e=
8c7c) [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 ca=
se, compared to key lookups.

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

```
lourens@CarbonX1:~/src/ruby/ruby$ make benchmark ITEM=3Dfiber_locals COMPAR=
E_RUBY=3D"~/src/ruby/trunk/ruby" OPTS=3D"--repeat-count 12 -v -r memory"
/usr/local/bin/ruby --disable=3Dgems -rrubygems -I./benchmark/lib ./benchma=
rk/benchmark-driver/exe/benchmark-driver \
            --executables=3D"compare-ruby::~/src/ruby/trunk/ruby -I.ext/com=
mon --disable-gem" \
            --executables=3D"built-ruby::./miniruby -I./lib -I. -I.ext/comm=
on  ./tool/runruby.rb --extout=3D.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_6=
4-linux]
built-ruby: ruby 2.8.0dev (2020-01-04T00:45:58Z ec-local-storage-i.. 333a5e=
8c7c) [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?



-- =

https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>