summaryrefslogtreecommitdiff
path: root/include/ruby
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2025-05-10 16:18:33 +0200
committerJean Boussier <[email protected]>2025-05-14 14:41:46 +0200
commitb5575a80bc3849651c395d0ae470eb41dc3aa897 ()
treedd6c002def6b08de4e58ddb534084d313627644e /include/ruby
parent920dc0fe3aafaf4d70f742abf846d7a2d9c142c4 (diff)
Reduce `Object#object_id` contention.
If the object isn't shareable and already has a object_id we can access it without a lock. If we need to generate an ID, we may need to lock to find the child shape. We also generate the next `object_id` using atomics.
Notes: Merged: https://.com/ruby/ruby/pull/13298
-rw-r--r--include/ruby/atomic.h44
1 files changed, 44 insertions, 0 deletions
@@ -198,6 +198,18 @@ typedef unsigned int rb_atomic_t;
#define RUBY_ATOMIC_DEC(var) rbimpl_atomic_dec(&(var))
/**
* Identical to #RUBY_ATOMIC_INC, except it expects its argument is `size_t`.
* There are cases where ::rb_atomic_t is 32bit while `size_t` is 64bit. This
* should be used for size related operations to support such platforms.
@@ -401,6 +413,38 @@ rbimpl_atomic_fetch_add(volatile rb_atomic_t *ptr, rb_atomic_t val)
#endif
}
RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))