Project

General

Profile

Actions

Feature #16563

open

Let rb_mod_const_at and rb_const_list use an ID table instead for inherited VS private constant segregation

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

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

Description

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, which were in fact pointers to ST tables, I don't think this change would / should 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=constants COMPARE_RUBY=~/src/ruby/trunk/ruby OPTS="-v --repeat-count 12 --repeat-result median"
/usr/local/bin/ruby --disable=gems -rrubygems -I./benchmark/lib ./benchmark/benchmark-driver/exe/benchmark-driver \
            --executables="compare-ruby::/home/lourens/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 'constants' -o -name '*constants*.yml' -o -name '*constants*.rb' | sort) -v --repeat-count 12 --repeat-result median
compare-ruby: ruby 2.8.0dev (2020-01-15T01:50:53Z master ac93cf4ff8) [x86_64-linux]
built-ruby: ruby 2.8.0dev (2020-01-15T02:06:58Z opt-const-at 3d5e2d4f68) [x86_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

No data to display

Actions

Also available in: Atom PDF

Like0