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.
This commit is contained in:
Alan Wu 2024-07-22 18:29:27 -04:00
Родитель 10574857ce
Коммит 83b0cedffe
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -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;