Skip to content

Commit 0df531a

Browse files
authored
Merge pull request #687 from lightpanda-io/always_gc_hints
Remove --gc_hints option, apply the --gc_hints behavior by default
2 parents 46c6a0b + b1d0368 commit 0df531a

File tree

5 files changed

+5
-32
lines changed

5 files changed

+5
-32
lines changed

.github/workflows/e2e-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ jobs:
8888
- name: run puppeteer
8989
run: |
9090
python3 -m http.server 1234 -d ./public & echo $! > PYTHON.pid
91-
./lightpanda serve --gc_hints & echo $! > LPD.pid
91+
./lightpanda serve & echo $! > LPD.pid
9292
RUNS=100 npm run bench-puppeteer-cdp > puppeteer.out || exit 1
9393
cat /proc/`cat LPD.pid`/status |grep VmHWM|grep -oP '\d+' > LPD.VmHWM
9494
kill `cat LPD.pid` `cat PYTHON.pid`

src/app.zig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ pub const App = struct {
2828

2929
pub const Config = struct {
3030
run_mode: RunMode,
31-
gc_hints: bool = false,
3231
tls_verify_host: bool = true,
3332
http_proxy: ?std.Uri = null,
3433
};

src/browser/browser.zig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ pub const Browser = struct {
8686
session.deinit();
8787
self.session = null;
8888
_ = self.session_arena.reset(.{ .retain_with_limit = 1 * 1024 * 1024 });
89-
if (self.app.config.gc_hints) {
90-
self.env.lowMemoryNotification();
91-
}
89+
self.env.lowMemoryNotification();
9290
}
9391
}
9492

src/main.zig

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ pub fn main() !void {
7070

7171
var app = try App.init(alloc, .{
7272
.run_mode = args.mode,
73-
.gc_hints = args.gcHints(),
7473
.http_proxy = args.httpProxy(),
7574
.tls_verify_host = args.tlsVerifyHost(),
7675
});
@@ -129,13 +128,6 @@ const Command = struct {
129128
mode: Mode,
130129
exec_name: []const u8,
131130

132-
fn gcHints(self: *const Command) bool {
133-
return switch (self.mode) {
134-
.serve => |opts| opts.gc_hints,
135-
else => false,
136-
};
137-
}
138-
139131
fn tlsVerifyHost(self: *const Command) bool {
140132
return switch (self.mode) {
141133
inline .serve, .fetch => |opts| opts.tls_verify_host,
@@ -161,7 +153,6 @@ const Command = struct {
161153
host: []const u8,
162154
port: u16,
163155
timeout: u16,
164-
gc_hints: bool,
165156
tls_verify_host: bool,
166157
http_proxy: ?std.Uri,
167158
};
@@ -210,9 +201,6 @@ const Command = struct {
210201
\\--timeout Inactivity timeout in seconds before disconnecting clients
211202
\\ Defaults to 3 (seconds)
212203
\\
213-
\\--gc_hints Encourage V8 to cleanup garbage for each new browser context.
214-
\\ Defaults to false
215-
\\
216204
\\--insecure_disable_tls_host_verification
217205
\\ Disables host verification on all HTTP requests.
218206
\\ This is an advanced option which should only be
@@ -296,10 +284,6 @@ fn inferMode(opt: []const u8) ?App.RunMode {
296284
return .serve;
297285
}
298286

299-
if (std.mem.eql(u8, opt, "--gc_hints")) {
300-
return .serve;
301-
}
302-
303287
return null;
304288
}
305289

@@ -310,7 +294,6 @@ fn parseServeArgs(
310294
var host: []const u8 = "127.0.0.1";
311295
var port: u16 = 9222;
312296
var timeout: u16 = 3;
313-
var gc_hints = false;
314297
var tls_verify_host = true;
315298
var http_proxy: ?std.Uri = null;
316299

@@ -355,11 +338,6 @@ fn parseServeArgs(
355338
continue;
356339
}
357340

358-
if (std.mem.eql(u8, "--gc_hints", opt)) {
359-
gc_hints = true;
360-
continue;
361-
}
362-
363341
if (std.mem.eql(u8, "--http_proxy", opt)) {
364342
const str = args.next() orelse {
365343
log.err("--http_proxy argument requires an value", .{});
@@ -377,7 +355,6 @@ fn parseServeArgs(
377355
.host = host,
378356
.port = port,
379357
.timeout = timeout,
380-
.gc_hints = gc_hints,
381358
.http_proxy = http_proxy,
382359
.tls_verify_host = tls_verify_host,
383360
};

src/runtime/js.zig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,9 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
269269
}
270270

271271
// V8 doesn't immediately free memory associated with
272-
// a Context, it's managed by the garbage collector. So, when the
273-
// `gc_hints` option is enabled, we'll use the `lowMemoryNotification`
274-
// call on the isolate to encourage v8 to free any contexts which
275-
// have been freed.
272+
// a Context, it's managed by the garbage collector. We use the
273+
// `lowMemoryNotification` call on the isolate to encourage v8 to free
274+
// any contexts which have been freed.
276275
pub fn lowMemoryNotification(self: *Self) void {
277276
var handle_scope: v8.HandleScope = undefined;
278277
v8.HandleScope.init(&handle_scope, self.isolate);

0 commit comments

Comments
 (0)