diff options
author | Peter Zhu <[email protected]> | 2024-07-23 15:56:00 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2024-07-24 09:44:54 -0400 |
commit | 0a9f771e19cc472651a3ab66d916bb8f65aab11a (patch) | |
tree | fd24ec5de0369744e95a2d6afd67c727c128e7be | |
parent | 97449338d6cb42d9dd7c9ca61550616e7e6b6ef6 (diff) |
Don't check live slot count when multi-Ractor
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11233
-rw-r--r-- | gc/default.c | 10 |
1 files changed, 8 insertions, 2 deletions
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)); } |