Issue #13174 has been reported by Yura Sokolov.

----------------------------------------
Feature #13174: Smaller id_table on 64bit platform
https://bugs.ruby-lang.org/issues/13174

* Author: Yura Sokolov
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Reduce size of id_table by 25% on 64bit platform (19% on smallest table):

- embed collision bit into key
- use array of keys + array of values instead of array of struct item_t.
Both arrays allocated at once, and pointer to values is calculated.

Additional changes:
- stricter check in next_id_base.
  One bit is needed for collision check on 64bit platform.
  Range is more limited on 32bit platform with ID_SCOPE_SHIFT and RUBY_SPECIAL_SHIFT.
- stricter check for result of next_id_base.
  Rais exception in rb_sym2id, assert in rb_make_internal_id.
- allow to shrink id_table.
  Shrink was disabled for mix_table cause it leads to error in id_table type
  detection. Since mix_table were removed, it is safe to shrink it again.
- improve large table performance by mixin higher bits into step value.

Performance of small tables almost the same.
Mixing higher bits takes 1-2% for small tables on hit, but improves large table
performance.

Report: https://gist.github.com/funny-falcon/7a1af6b3891ae636b12237f25eb20690

https://github.com/funny-falcon/ruby/tree/smaller_id_table
https://github.com/ruby/ruby/compare/trunk...funny-falcon:smaller_id_table.patch


---Files--------------------------------
improve_id_table.patch (10.2 KB)


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

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