@@ -158,7 +158,7 @@ function maybe_collect(; blocking::Bool = false)
158
158
159
159
# Check if we are under memory pressure.
160
160
pressure = stats. live / stats. size
161
- min_pressure = blocking ? 0.5 : 0.75
161
+ min_pressure = 0.5
162
162
pressure < min_pressure && return
163
163
164
164
# TODO take allocations into account
@@ -170,30 +170,26 @@ function maybe_collect(; blocking::Bool = false)
170
170
# Tolerate 5% GC time.
171
171
max_gc_rate = 0.05
172
172
# If freed a lot of memory last time, double max GC rate.
173
- freed_alot = stats. last_freed > 0.1 * stats. size
174
- freed_alot && (max_gc_rate *= 2 ;)
173
+ (stats. last_freed > 0.1 * stats. size) && (max_gc_rate *= 2 ;)
175
174
# Be more aggressive if we are going to block.
176
175
blocking && (max_gc_rate *= 2 ;)
177
176
178
177
# And even more if the pressure is high.
179
- pressure > 0.5 && (max_gc_rate *= 2 ;)
180
- pressure > 0.7 && (max_gc_rate *= 2 ;)
181
-
182
- # Always free if pressure is 0.9 and we freed a lot.
183
- pressure > 0.9 && (max_gc_rate *= freed_alot ? Inf : 2 ;)
178
+ pressure > 0.6 && (max_gc_rate *= 2 ;)
179
+ pressure > 0.8 && (max_gc_rate *= 2 ;)
184
180
gc_rate > max_gc_rate && return
185
181
186
- # Call the GC.
187
182
Base. @atomic stats. last_time = current_time
183
+
184
+ # Call the GC.
188
185
pre_gc_live = stats. live
189
- gc_time = Base. @elapsed GC. gc (pressure > 0.7 ? true : false )
186
+ gc_time = Base. @elapsed GC. gc (pressure > 0.8 ? true : false )
190
187
post_gc_live = stats. live
191
188
192
189
# Update stats.
193
190
freed = pre_gc_live - post_gc_live
194
191
Base. @atomic stats. last_freed = freed
195
- # Smooth out GC times.
196
- Base. @atomic stats. last_gc_time = 0.75 * stats. last_gc_time + 0.25 * gc_time
192
+ Base. @atomic stats. last_gc_time = gc_time
197
193
return
198
194
end
199
195
0 commit comments