Lightpanda: the headless browser designed for AI and automation
v8, perf: Reduce v8 GC hint frequency.
Karl Seguineca8baf8ed28
diff --git a/src/browser/Runner.zig b/src/browser/Runner.zigindex bf11efb82..03ebe3069 100644--- a/src/browser/Runner.zig+++ b/src/browser/Runner.zig@@ -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) {diff --git a/src/browser/js/Env.zig b/src/browser/js/Env.zigindex e0dbc5cde..238fba541 100644--- a/src/browser/js/Env.zig+++ b/src/browser/js/Env.zig@@ -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);diff --git a/src/browser/js/Isolate.zig b/src/browser/js/Isolate.zigindex fcb8eeadb..61cf3cb43 100644--- a/src/browser/js/Isolate.zig+++ b/src/browser/js/Isolate.zig@@ -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,