@@ -758,7 +758,6 @@ int current_sweep_full = 0;
758
758
int under_pressure = 0 ;
759
759
760
760
// Full collection heuristics
761
- static int64_t pool_live_bytes = 0 ;
762
761
static int64_t live_bytes = 0 ;
763
762
static int64_t promoted_bytes = 0 ;
764
763
static int64_t last_live_bytes = 0 ; // live_bytes at last collection
@@ -1333,6 +1332,8 @@ STATIC_INLINE jl_value_t *jl_gc_pool_alloc_inner(jl_ptls_t ptls, int pool_offset
1333
1332
maybe_collect (ptls );
1334
1333
jl_atomic_store_relaxed (& ptls -> gc_num .allocd ,
1335
1334
jl_atomic_load_relaxed (& ptls -> gc_num .allocd ) + osize );
1335
+ jl_atomic_store_relaxed (& ptls -> gc_num .pool_live_bytes ,
1336
+ jl_atomic_load_relaxed (& ptls -> gc_num .pool_live_bytes ) + osize );
1336
1337
jl_atomic_store_relaxed (& ptls -> gc_num .poolalloc ,
1337
1338
jl_atomic_load_relaxed (& ptls -> gc_num .poolalloc ) + 1 );
1338
1339
// first try to use the freelist
@@ -1520,7 +1521,8 @@ static void gc_sweep_page(jl_gc_pool_t *p, jl_gc_page_stack_t *allocd, jl_gc_pag
1520
1521
}
1521
1522
}
1522
1523
gc_time_count_page (freedall , pg_skpd );
1523
- jl_atomic_fetch_add ((_Atomic (int64_t ) * )& pool_live_bytes , GC_PAGE_SZ - GC_PAGE_OFFSET - nfree * osize );
1524
+ jl_ptls_t ptls = gc_all_tls_states [pg -> thread_n ];
1525
+ jl_atomic_fetch_add (& ptls -> gc_num .pool_live_bytes , GC_PAGE_SZ - GC_PAGE_OFFSET - nfree * osize );
1524
1526
jl_atomic_fetch_add ((_Atomic (int64_t ) * )& gc_num .freed , (nfree - old_nfree ) * osize );
1525
1527
}
1526
1528
@@ -1642,6 +1644,7 @@ static void gc_sweep_pool(void)
1642
1644
}
1643
1645
continue ;
1644
1646
}
1647
+ jl_atomic_store_relaxed (& ptls2 -> gc_num .pool_live_bytes , 0 );
1645
1648
for (int i = 0 ; i < JL_GC_N_POOLS ; i ++ ) {
1646
1649
jl_gc_pool_t * p = & ptls2 -> heap .norm_pools [i ];
1647
1650
jl_taggedvalue_t * last = p -> freelist ;
@@ -3182,6 +3185,13 @@ JL_DLLEXPORT int64_t jl_gc_sync_total_bytes(int64_t offset) JL_NOTSAFEPOINT
3182
3185
3183
3186
JL_DLLEXPORT int64_t jl_gc_pool_live_bytes (void )
3184
3187
{
3188
+ int64_t pool_live_bytes = 0 ;
3189
+ for (int i = 0 ; i < gc_n_threads ; i ++ ) {
3190
+ jl_ptls_t ptls2 = gc_all_tls_states [i ];
3191
+ if (ptls2 != NULL ) {
3192
+ pool_live_bytes += jl_atomic_load_relaxed (& ptls2 -> gc_num .pool_live_bytes );
3193
+ }
3194
+ }
3185
3195
return pool_live_bytes ;
3186
3196
}
3187
3197
@@ -3346,7 +3356,6 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
3346
3356
promoted_bytes = 0 ;
3347
3357
}
3348
3358
scanned_bytes = 0 ;
3349
- pool_live_bytes = 0 ;
3350
3359
// 6. start sweeping
3351
3360
uint64_t start_sweep_time = jl_hrtime ();
3352
3361
JL_PROBE_GC_SWEEP_BEGIN (sweep_full );
0 commit comments