@@ -3059,12 +3059,14 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
3059
3059
3060
3060
// update heuristics only if this GC was automatically triggered
3061
3061
if (collection == JL_GC_AUTO ) {
3062
- if (not_freed_enough ) {
3063
- gc_num .interval = gc_num .interval * 2 ;
3064
- }
3065
3062
if (large_frontier ) {
3066
3063
sweep_full = 1 ;
3064
+ gc_num .interval = last_long_collect_interval ;
3067
3065
}
3066
+ if (not_freed_enough || large_frontier ) {
3067
+ gc_num .interval = gc_num .interval * 2 ;
3068
+ }
3069
+
3068
3070
size_t maxmem = 0 ;
3069
3071
#ifdef _P64
3070
3072
// on a big memory machine, increase max_collect_interval to totalmem / nthreads / 2
@@ -3097,6 +3099,7 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
3097
3099
// on the first collection after sweep_full, and the current scan
3098
3100
perm_scanned_bytes = 0 ;
3099
3101
promoted_bytes = 0 ;
3102
+ last_long_collect_interval = gc_num .interval ;
3100
3103
}
3101
3104
scanned_bytes = 0 ;
3102
3105
// 6. start sweeping
@@ -3166,22 +3169,34 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
3166
3169
live_bytes += - gc_num .freed + gc_num .since_sweep ;
3167
3170
3168
3171
if (collection == JL_GC_AUTO ) {
3172
+ //If we aren't freeing enough or are seeing lots and lots of pointers let it increase faster
3173
+ if (!not_freed_enough || large_frontier ) {
3174
+ int64_t tot = 2 * (live_bytes + gc_num .since_sweep ) / 3 ;
3175
+ if (gc_num .interval > tot ) {
3176
+ gc_num .interval = tot ;
3177
+ last_long_collect_interval = tot ;
3178
+ }
3169
3179
// If the current interval is larger than half the live data decrease the interval
3170
- int64_t half = live_bytes /2 ;
3171
- if (gc_num .interval > half ) gc_num .interval = half ;
3180
+ } else {
3181
+ int64_t half = (live_bytes / 2 );
3182
+ if (gc_num .interval > half )
3183
+ gc_num .interval = half ;
3184
+ }
3185
+
3172
3186
// But never go below default
3173
3187
if (gc_num .interval < default_collect_interval ) gc_num .interval = default_collect_interval ;
3174
3188
}
3175
3189
3176
3190
if (gc_num .interval + live_bytes > max_total_memory ) {
3177
3191
if (live_bytes < max_total_memory ) {
3178
3192
gc_num .interval = max_total_memory - live_bytes ;
3193
+ last_long_collect_interval = max_total_memory - live_bytes ;
3179
3194
}
3180
3195
else {
3181
3196
// We can't stay under our goal so let's go back to
3182
3197
// the minimum interval and hope things get better
3183
3198
gc_num .interval = default_collect_interval ;
3184
- }
3199
+ }
3185
3200
}
3186
3201
3187
3202
gc_time_summary (sweep_full , t_start , gc_end_time , gc_num .freed ,
0 commit comments