Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precompute embedded string literals hash code #10596

Merged
merged 1 commit into from
May 28, 2024

Commits on May 14, 2024

  1. Precompute embedded string literals hash code

    With embedded strings we often have some space left in the slot, which
    we can use to store the string Hash code.
    
    It's probably only worth it for string literals, as they are the ones
    likely to be used as hash keys.
    
    We chose to store the Hash code right after the string terminator as to
    make it easy/fast to compute, and not require one more union in RString.
    
    ```
    compare-ruby: ruby 3.4.0dev (2024-04-22T06:32:21Z main f77618c) [arm64-darwin23]
    built-ruby: ruby 3.4.0dev (2024-04-22T10:13:03Z interned-string-ha.. 8a1a32331b) [arm64-darwin23]
    last_commit=Precompute embedded string literals hash code
    
    |            |compare-ruby|built-ruby|
    |:-----------|-----------:|---------:|
    |symbol      |     39.275M|   39.753M|
    |            |           -|     1.01x|
    |dyn_symbol  |     37.348M|   37.704M|
    |            |           -|     1.01x|
    |small_lit   |     29.514M|   33.948M|
    |            |           -|     1.15x|
    |frozen_lit  |     27.180M|   33.056M|
    |            |           -|     1.22x|
    |iseq_lit    |     27.391M|   32.242M|
    |            |           -|     1.18x|
    ```
    
    Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
    byroot and etiennebarrie committed May 14, 2024
    Configuration menu
    Copy the full SHA
    85b5a30 View commit details
    Browse the repository at this point in the history