diff --git a/gc/default.c b/gc/default.c index 7b7b4694e4..5717baac2b 100644 --- a/gc/default.c +++ b/gc/default.c @@ -626,6 +626,7 @@ typedef struct rb_objspace { rb_postponed_job_handle_t finalize_deferred_pjob; unsigned long live_ractor_cache_count; + bool multi_ractor_p; } rb_objspace_t; #ifndef HEAP_PAGE_ALIGN_LOG @@ -2609,7 +2610,7 @@ newobj_alloc(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache, size_t si } } - RUBY_ATOMIC_SIZE_ADD(size_pool->total_allocated_objects, 1); + size_pool->total_allocated_objects++; return obj; } @@ -5397,7 +5398,8 @@ gc_verify_internal_consistency_(rb_objspace_t *objspace) /* check counters */ if (!is_lazy_sweeping(objspace) && - !finalizing) { + !finalizing && + !objspace->multi_ractor_p) { if (objspace_live_slots(objspace) != data.live_object_count) { fprintf(stderr, "heap_pages_final_slots: %"PRIdSIZE", total_freed_objects: %"PRIdSIZE"\n", heap_pages_final_slots, total_freed_objects(objspace)); @@ -6420,6 +6422,10 @@ rb_gc_impl_ractor_cache_alloc(void *objspace_ptr) objspace->live_ractor_cache_count++; + if (objspace->live_ractor_cache_count > 1) { + objspace->multi_ractor_p = true; + } + return calloc1(sizeof(rb_ractor_newobj_cache_t)); }