Merge pull request #3005 from lightpanda-io/reduce-gc-hint-frequency

perf, v8: reduce gc hint frequency
This commit is contained in:
Karl Seguin
2026-07-21 18:44:19 +08:00
committed by GitHub
3 changed files with 1 additions and 19 deletions

View File

@@ -121,7 +121,7 @@ fn _wait(self: *Runner, comptime is_cdp: bool, timeout_ms: u32, conditions: []Wa
// alive for seconds while running heavy JS accumulates wrappers and
// external-ref'd Zig allocations V8 has no reason to drop. `.moderate`
// speeds up incremental GC without stalling the tick.
const gc_hint_period_ns: u64 = std.time.ns_per_s;
const gc_hint_period_ns: u64 = std.time.ns_per_s * 5;
var gc_hint_timer = std.time.Timer.start() catch unreachable;
while (true) {

View File

@@ -501,19 +501,6 @@ pub fn runIdleTasks(self: *const Env) void {
v8.v8__Platform__RunIdleTasks(self.platform.handle, self.isolate.handle, 1);
}
// V8 doesn't immediately free memory associated with
// a Context, it's managed by the garbage collector. We use the
// `lowMemoryNotification` call on the isolate to encourage v8 to free
// any contexts which have been freed.
// This GC is very aggressive. Use memoryPressureNotification for less
// aggressive GC passes.
pub fn lowMemoryNotification(self: *Env) void {
var handle_scope: js.HandleScope = undefined;
handle_scope.init(self.isolate);
defer handle_scope.deinit();
self.isolate.lowMemoryNotification();
}
// V8 doesn't immediately free memory associated with
// a Context, it's managed by the garbage collector. We use the
// `memoryPressureNotification` call on the isolate to encourage v8 to free
@@ -521,7 +508,6 @@ pub fn lowMemoryNotification(self: *Env) void {
// The level indicates the aggressivity of the GC required:
// moderate speeds up incremental GC
// critical runs one full GC
// For a more aggressive GC, use lowMemoryNotification.
pub fn memoryPressureNotification(self: *Env, level: Isolate.MemoryPressureLevel) void {
var handle_scope: js.HandleScope = undefined;
handle_scope.init(self.isolate);

View File

@@ -41,10 +41,6 @@ pub fn exit(self: Isolate) void {
v8.v8__Isolate__Exit(self.handle);
}
pub fn lowMemoryNotification(self: Isolate) void {
v8.v8__Isolate__LowMemoryNotification(self.handle);
}
pub const MemoryPressureLevel = enum(u32) {
none = v8.kNone,
moderate = v8.kModerate,