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

----------------------------------------
Feature #16563: Let rb_mod_const_at and rb_const_list use an ID table inste=
ad for inherited VS private constant segregation
https://bugs.ruby-lang.org/issues/16563

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

* Target version: =

----------------------------------------
References https://github.com/ruby/ruby/pull/2840

It feels unnatural to cast an `ID` to `st_data_t` if we already a ID table =
implementation.

Despite these declarations in `ruby/intern.h` returning void pointers, whic=
h were in fact pointers to ST tables, I don't think this change would / sho=
uld break any extensions:

```
void *rb_mod_const_at(VALUE, void*);
void *rb_mod_const_of(VALUE, void*);
```

```
lourens@CarbonX1:~/src/ruby/ruby$ make benchmark ITEM=3Dconstants COMPARE_R=
UBY=3D~/src/ruby/trunk/ruby OPTS=3D"-v --repeat-count 12 --repeat-result me=
dian"
/usr/local/bin/ruby --disable=3Dgems -rrubygems -I./benchmark/lib ./benchma=
rk/benchmark-driver/exe/benchmark-driver \
            --executables=3D"compare-ruby::/home/lourens/src/ruby/trunk/rub=
y -I.ext/common --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 'constants' -o -name '*con=
stants*.yml' -o -name '*constants*.rb' | sort) -v --repeat-count 12 --repea=
t-result median
compare-ruby: ruby 2.8.0dev (2020-01-15T01:50:53Z master ac93cf4ff8) [x86_6=
4-linux]
built-ruby: ruby 2.8.0dev (2020-01-15T02:06:58Z opt-const-at 3d5e2d4f68) [x=
86_64-linux]
Calculating -------------------------------------
                     compare-ruby  built-ruby =

                 all     412.156k    519.808k i/s -      1.000M times in 2.=
443206s 1.932313s
           inherited     431.349k    522.407k i/s -      1.000M times in 2.=
338914s 1.930936s

Comparison:
                              all
          built-ruby:    519808.1 i/s =

        compare-ruby:    412156.0 i/s - 1.26x  slower

                        inherited
          built-ruby:    522406.7 i/s =

        compare-ruby:    431348.9 i/s - 1.21x  slower
```



-- =

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>