@@ -2090,6 +2090,11 @@ STATIC_INLINE void gc_mark_objarray(jl_ptls_t ptls, jl_value_t *obj_parent, jl_v
20902090 obj_end = obj_begin + step * MAX_REFS_AT_ONCE ;
20912091 }
20922092 for (; obj_begin < obj_end ; obj_begin += step ) {
2093+ if (obj_begin + 64 * step < obj_end ){
2094+ __builtin_prefetch (& jl_astaggedvalue (* (obj_begin + 32 * step ))-> header , 1 );
2095+ __builtin_prefetch (* (obj_begin + 48 * step ));
2096+ __builtin_prefetch ((obj_begin + 64 * step ));
2097+ }
20932098 new_obj = * obj_begin ;
20942099 if (new_obj != NULL ) {
20952100 verify_parent2 ("obj array" , obj_parent , obj_begin , "elem(%d)" ,
@@ -3059,12 +3064,14 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
30593064
30603065 // update heuristics only if this GC was automatically triggered
30613066 if (collection == JL_GC_AUTO ) {
3062- if (not_freed_enough ) {
3063- gc_num .interval = gc_num .interval * 2 ;
3064- }
30653067 if (large_frontier ) {
30663068 sweep_full = 1 ;
3069+ gc_num .interval = last_long_collect_interval ;
30673070 }
3071+ if (not_freed_enough || large_frontier ) {
3072+ gc_num .interval = gc_num .interval * 2 ;
3073+ }
3074+
30683075 size_t maxmem = 0 ;
30693076#ifdef _P64
30703077 // on a big memory machine, increase max_collect_interval to totalmem / nthreads / 2
@@ -3097,6 +3104,7 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
30973104 // on the first collection after sweep_full, and the current scan
30983105 perm_scanned_bytes = 0 ;
30993106 promoted_bytes = 0 ;
3107+ last_long_collect_interval = gc_num .interval ;
31003108 }
31013109 scanned_bytes = 0 ;
31023110 // 6. start sweeping
@@ -3166,16 +3174,29 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
31663174 live_bytes += - gc_num .freed + gc_num .since_sweep ;
31673175
31683176 if (collection == JL_GC_AUTO ) {
3177+ //If we aren't freeing enough or are seeing lots and lots of pointers let it increase faster
3178+ if (!not_freed_enough || large_frontier ) {
3179+ int64_t tot = 2 * (live_bytes + gc_num .since_sweep )/3 ;
3180+ if (gc_num .interval > tot ) {
3181+ gc_num .interval = tot ;
3182+ last_long_collect_interval = tot ;
3183+ }
31693184 // 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 ;
3185+ }
3186+ else {
3187+ int64_t half = (live_bytes );
3188+ if (gc_num .interval > half )
3189+ gc_num .interval = half ;
3190+ }
3191+
31723192 // But never go below default
31733193 if (gc_num .interval < default_collect_interval ) gc_num .interval = default_collect_interval ;
31743194 }
31753195
31763196 if (gc_num .interval + live_bytes > max_total_memory ) {
31773197 if (live_bytes < max_total_memory ) {
31783198 gc_num .interval = max_total_memory - live_bytes ;
3199+ last_long_collect_interval = max_total_memory - live_bytes ;
31793200 }
31803201 else {
31813202 // We can't stay under our goal so let's go back to
0 commit comments