diff options
| author | Alan Wu <XrXr@users.noreply.github.com> | 2024-07-22 18:29:27 -0400 |
|---|---|---|
| committer | Alan Wu <XrXr@users.noreply.github.com> | 2024-07-25 12:46:33 -0400 |
| commit | 83b0cedffe5a9bd6c5288fa0d9614d6ca39e63e8 (patch) | |
| tree | edcebff8b2d2d632b31f78e542bd1c7d6af858d1 | |
| parent | 10574857ce167869524b97ee862b610928f6272f (diff) | |
Add branch prediction annotations for object allocation
I get a slight boost from these with GCC 11 on Intel Skylake.
Part of a larger story to fix an allocation throughput regression
compared to 98eeadc ("Development of 3.4.0 started.") as the baseline.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11223
| -rw-r--r-- | gc/default.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gc/default.c b/gc/default.c index 5717baac2b..fc093b1c27 100644 --- a/gc/default.c +++ b/gc/default.c @@ -2450,7 +2450,7 @@ ractor_cache_allocate_slot(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *ca rb_ractor_newobj_size_pool_cache_t *size_pool_cache = &cache->size_pool_caches[size_pool_idx]; struct free_slot *p = size_pool_cache->freelist; - if (is_incremental_marking(objspace)) { + if (RB_UNLIKELY(is_incremental_marking(objspace))) { // Not allowed to allocate without running an incremental marking step if (cache->incremental_mark_step_allocated_slots >= INCREMENTAL_MARK_STEP_ALLOCATIONS) { return Qfalse; @@ -2461,7 +2461,7 @@ ractor_cache_allocate_slot(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *ca } } - if (p) { + if (RB_LIKELY(p)) { VALUE obj = (VALUE)p; MAYBE_UNUSED(const size_t) stride = size_pool_slot_size(size_pool_idx); size_pool_cache->freelist = p->next; |
