Skip to content
  • Jean Boussier's avatar
    0606046c
    Lazily create `objspace->id_to_obj_tbl` · 0606046c
    Jean Boussier authored
    This inverse table is only useful if `ObjectSpace._id2ref` is used,
    which is extremely rare. The only notable exception is the `drb` gem
    and even then it has an option not to rely on `_id2ref`.
    
    So if we assume this table will never be looked up, we can just
    not maintain it, and if it turns out `_id2ref` is called, we
    can lock the VM and re-build it.
    
    ```
    compare-ruby: ruby 3.5.0dev (2025-04-10T09:44:40Z master 684cfa42) +YJIT +PRISM [arm64-darwin24]
    built-ruby: ruby 3.5.0dev (2025-04-10T10:13:43Z lazy-id-to-obj d3aa9626cc) +YJIT +PRISM [arm64-darwin24]
    warming up..
    
    |           |compare-ruby|built-ruby|
    |:----------|-----------:|---------:|
    |baseline   |     26.364M|   25.974M|
    |           |       1.01x|         -|
    |object_id  |     10.293M|   14.202M|
    |           |           -|     1.38x|
    ```
    0606046c
    Lazily create `objspace->id_to_obj_tbl`
    Jean Boussier authored
    This inverse table is only useful if `ObjectSpace._id2ref` is used,
    which is extremely rare. The only notable exception is the `drb` gem
    and even then it has an option not to rely on `_id2ref`.
    
    So if we assume this table will never be looked up, we can just
    not maintain it, and if it turns out `_id2ref` is called, we
    can lock the VM and re-build it.
    
    ```
    compare-ruby: ruby 3.5.0dev (2025-04-10T09:44:40Z master 684cfa42) +YJIT +PRISM [arm64-darwin24]
    built-ruby: ruby 3.5.0dev (2025-04-10T10:13:43Z lazy-id-to-obj d3aa9626cc) +YJIT +PRISM [arm64-darwin24]
    warming up..
    
    |           |compare-ruby|built-ruby|
    |:----------|-----------:|---------:|
    |baseline   |     26.364M|   25.974M|
    |           |       1.01x|         -|
    |object_id  |     10.293M|   14.202M|
    |           |           -|     1.38x|
    ```
Loading