|
126 | 126 | #else |
127 | 127 | #define psweep_debug(...) (void)0 |
128 | 128 | #endif |
129 | | -#define PSWEEP_LOCK_STATS 1 |
| 129 | +#define PSWEEP_LOCK_STATS 0 |
130 | 130 | #define PSWEEP_COLLECT_TIMINGS 0 |
131 | 131 |
|
132 | 132 | #ifndef GC_HEAP_FREE_SLOTS |
@@ -4554,10 +4554,8 @@ gc_pre_sweep_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *pa |
4554 | 4554 | int total_slots = page->total_slots; |
4555 | 4555 | psweep_debug(1, "[sweep] gc_pre_sweep_page(heap:%p page:%p) start\n", heap, page); |
4556 | 4556 | GC_ASSERT(page->heap == heap); |
4557 | | - page->pre_deferred_free_slots = 0; |
4558 | | - memset(page->deferred_free_bits, 0, sizeof(page->deferred_free_bits)); |
4559 | | - page->pre_zombie_slots = 0; |
4560 | | - page->pre_freed_malloc_bytes = 0; |
| 4557 | + GC_ASSERT(page->pre_deferred_free_slots == 0); |
| 4558 | + GC_ASSERT(page->pre_freed_malloc_bytes == 0); |
4561 | 4559 | current_sweep_thread_page = page; |
4562 | 4560 |
|
4563 | 4561 | int bitmap_plane_count = CEILDIV(total_slots, BITS_BITLENGTH); |
@@ -4602,6 +4600,8 @@ gc_pre_sweep_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *pa |
4602 | 4600 | #endif |
4603 | 4601 |
|
4604 | 4602 | #if USE_MALLOC_INCREASE_LOCAL |
| 4603 | + // flush to sweep_page->pre_freed_malloc_bytes instead of malloc_increase because it's clamped at 0 right now and |
| 4604 | + // we don't want to decrease it too quickly |
4605 | 4605 | malloc_increase_local_flush(objspace); |
4606 | 4606 | #endif |
4607 | 4607 | current_sweep_thread_page = NULL; |
@@ -9958,13 +9958,7 @@ bad_malloc_during_gc_p(rb_objspace_t *objspace) |
9958 | 9958 | * (since ractors can run while another thread is sweeping) and when we |
9959 | 9959 | * have the GVL (since if we don't have the GVL, we'll try to acquire the |
9960 | 9960 | * GVL which will block and ensure the other thread finishes GC). */ |
9961 | | - if (is_sweep_thread_p()) { |
9962 | | - fprintf(stderr, "ERROR: bad malloc/calloc call family during GC in sweep thread!\n"); |
9963 | | - return true; |
9964 | | - } |
9965 | | - else { |
9966 | | - return during_gc && !dont_gc_val() && !rb_gc_multi_ractor_p() && ruby_thread_has_gvl_p(); |
9967 | | - } |
| 9961 | + return during_gc && !dont_gc_val() && !rb_gc_multi_ractor_p() && ruby_thread_has_gvl_p(); |
9968 | 9962 | } |
9969 | 9963 |
|
9970 | 9964 | static inline void * |
|
0 commit comments