@@ -996,7 +996,6 @@ struct heap_page {
996996 unsigned short pre_deferred_free_slots ;
997997 unsigned short pre_final_slots ;
998998 unsigned short pre_zombie_slots ;
999- size_t pre_freed_malloc_bytes ;
1000999#endif
10011000};
10021001
@@ -4771,7 +4770,6 @@ gc_pre_sweep_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *pa
47714770 psweep_debug (1 , "[sweep] gc_pre_sweep_page(heap:%p page:%p) start\n" , heap , page );
47724771 GC_ASSERT (page -> heap == heap );
47734772 GC_ASSERT (page -> pre_deferred_free_slots == 0 );
4774- GC_ASSERT (page -> pre_freed_malloc_bytes == 0 );
47754773#if USE_MALLOC_INCREASE_LOCAL
47764774 current_sweep_thread_page = page ;
47774775#endif
@@ -4818,14 +4816,6 @@ gc_pre_sweep_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *pa
48184816 }
48194817 }
48204818#endif
4821-
4822- #if USE_MALLOC_INCREASE_LOCAL
4823- // flush to sweep_page->pre_freed_malloc_bytes instead of malloc_increase because it's clamped at 0 right now and
4824- // we don't want to decrease it too quickly
4825- malloc_increase_local_flush (objspace );
4826- current_sweep_thread_page = NULL ;
4827- #endif
4828-
48294819 psweep_debug (1 , "[sweep] gc_pre_sweep_page(heap:%p page:%p) done, deferred free:%d\n" , heap , page , page -> pre_deferred_free_slots );
48304820}
48314821
@@ -4894,10 +4884,6 @@ clear_pre_sweep_fields(rb_objspace_t *objspace, struct heap_page *page)
48944884 page -> pre_empty_slots = 0 ;
48954885 page -> pre_final_slots = 0 ;
48964886 page -> pre_zombie_slots = 0 ;
4897- if (RB_UNLIKELY (page -> pre_freed_malloc_bytes > 0 )) {
4898- malloc_increase_commit (objspace , 0 , page -> pre_freed_malloc_bytes , NULL );
4899- page -> pre_freed_malloc_bytes = 0 ;
4900- }
49014887}
49024888
49034889#define SWEEP_CHUNK 4
@@ -5235,6 +5221,9 @@ gc_sweep_thread_func(void *ptr)
52355221 goto restart_heaps ;
52365222 }
52375223 }
5224+ #if USE_MALLOC_INCREASE_LOCAL
5225+ malloc_increase_local_flush (objspace );
5226+ #endif
52385227
52395228 objspace -> sweep_thread_sweeping = false;
52405229 rb_native_cond_signal (& objspace -> sweep_cond ); // signal done sweeping this iteration
@@ -5867,11 +5856,6 @@ gc_sweep_step(rb_objspace_t *objspace, rb_heap_t *heap)
58675856 GC_ASSERT (sweep_page -> free_slots <= sweep_page -> total_slots );
58685857 GC_ASSERT (sweep_page -> final_slots <= sweep_page -> total_slots );
58695858 sweep_page -> heap -> total_freed_objects += ctx .freed_slots ;
5870-
5871- if (sweep_page -> pre_freed_malloc_bytes > 0 ) {
5872- malloc_increase_commit (objspace , 0 , sweep_page -> pre_freed_malloc_bytes , NULL );
5873- sweep_page -> pre_freed_malloc_bytes = 0 ;
5874- }
58755859 clear_pre_sweep_fields (objspace , sweep_page );
58765860 }
58775861#endif
@@ -10370,20 +10354,12 @@ malloc_increase_commit(rb_objspace_t *objspace, size_t new_size, size_t old_size
1037010354 }
1037110355 else if (old_size > new_size ) {
1037210356 size_t delta = old_size - new_size ;
10373- #if USE_PARALLEL_SWEEP
10374- if (sweep_thread_page ) {
10375- sweep_thread_page -> pre_freed_malloc_bytes += delta ;
10376- }
10377- else
10378- #endif
10379- {
10380- MALLOC_COUNTERS_LOCK (objspace );
10381- gc_counter_add (& objspace -> malloc_counters .counters .free , delta );
10357+ MALLOC_COUNTERS_LOCK (objspace );
10358+ gc_counter_add (& objspace -> malloc_counters .counters .free , delta );
1038210359#if RGENGC_ESTIMATE_OLDMALLOC
10383- gc_counter_add (& objspace -> malloc_counters .oldcounters .free , delta );
10360+ gc_counter_add (& objspace -> malloc_counters .oldcounters .free , delta );
1038410361#endif
10385- MALLOC_COUNTERS_UNLOCK (objspace );
10386- }
10362+ MALLOC_COUNTERS_UNLOCK (objspace );
1038710363 }
1038810364}
1038910365
0 commit comments