@@ -2090,6 +2090,11 @@ STATIC_INLINE void gc_mark_objarray(jl_ptls_t ptls, jl_value_t *obj_parent, jl_v
2090
2090
obj_end = obj_begin + step * MAX_REFS_AT_ONCE ;
2091
2091
}
2092
2092
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
+ }
2093
2098
new_obj = * obj_begin ;
2094
2099
if (new_obj != NULL ) {
2095
2100
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)
3059
3064
3060
3065
// update heuristics only if this GC was automatically triggered
3061
3066
if (collection == JL_GC_AUTO ) {
3062
- if (not_freed_enough ) {
3063
- gc_num .interval = gc_num .interval * 2 ;
3064
- }
3065
3067
if (large_frontier ) {
3066
3068
sweep_full = 1 ;
3069
+ gc_num .interval = last_long_collect_interval ;
3067
3070
}
3071
+ if (not_freed_enough || large_frontier ) {
3072
+ gc_num .interval = gc_num .interval * 2 ;
3073
+ }
3074
+
3068
3075
size_t maxmem = 0 ;
3069
3076
#ifdef _P64
3070
3077
// 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)
3097
3104
// on the first collection after sweep_full, and the current scan
3098
3105
perm_scanned_bytes = 0 ;
3099
3106
promoted_bytes = 0 ;
3107
+ last_long_collect_interval = gc_num .interval ;
3100
3108
}
3101
3109
scanned_bytes = 0 ;
3102
3110
// 6. start sweeping
@@ -3166,16 +3174,29 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
3166
3174
live_bytes += - gc_num .freed + gc_num .since_sweep ;
3167
3175
3168
3176
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
+ }
3169
3184
// 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
+
3172
3192
// But never go below default
3173
3193
if (gc_num .interval < default_collect_interval ) gc_num .interval = default_collect_interval ;
3174
3194
}
3175
3195
3176
3196
if (gc_num .interval + live_bytes > max_total_memory ) {
3177
3197
if (live_bytes < max_total_memory ) {
3178
3198
gc_num .interval = max_total_memory - live_bytes ;
3199
+ last_long_collect_interval = max_total_memory - live_bytes ;
3179
3200
}
3180
3201
else {
3181
3202
// We can't stay under our goal so let's go back to
0 commit comments