diff options
author | Jean Boussier <[email protected]> | 2025-04-10 11:53:39 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2025-04-15 07:57:39 +0900 |
commit | 0606046c1a3816eabb26b5de18942c02710eb28e (patch) | |
tree | c2f3b911f1071c1d7e3af27445f9f1c5fbad34b1 /gc.c | |
parent | b68172caada45724a302f337334f29ebae5a0e1e (diff) |
Lazily create `objspace->id_to_obj_tbl`
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 684cfa42d7) +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|
```
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13115
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1794,11 +1794,11 @@ id2ref(VALUE objid) return ptr; } else { - rb_raise(rb_eRangeError, "%p is not symbol id value", (void *)ptr); + rb_raise(rb_eRangeError, "%p is not a symbol id value", (void *)ptr); } } - rb_raise(rb_eRangeError, "%+"PRIsVALUE" is not id value", rb_int2str(objid, 10)); + rb_raise(rb_eRangeError, "%+"PRIsVALUE" is not an id value", rb_int2str(objid, 10)); } } @@ -1807,7 +1807,7 @@ id2ref(VALUE objid) return obj; } else { - rb_raise(rb_eRangeError, "%+"PRIsVALUE" is id of the unshareable object on multi-ractor", rb_int2str(objid, 10)); + rb_raise(rb_eRangeError, "%+"PRIsVALUE" is the id of an unshareable object on multi-ractor", rb_int2str(objid, 10)); } } |