diff options
author | 2023-05-23 00:44:56 -0700 | |
---|---|---|
committer | 2023-05-23 00:44:56 -0700 | |
commit | f71eb39b14b0177c178d68d86e1ba11f227044af (patch) | |
tree | 2b553ef9b5817ce640ff76075e5a89511228c46b | |
parent | de185bdc055cd8610458e035f76043a74cd26786 (diff) | |
download | bun-f71eb39b14b0177c178d68d86e1ba11f227044af.tar.gz bun-f71eb39b14b0177c178d68d86e1ba11f227044af.tar.zst bun-f71eb39b14b0177c178d68d86e1ba11f227044af.zip |
[bun:test] Don't schedule the GC aggressively on every file
We already run the GC automatically whenever heap size grows, so this is mostly unnecessary
In one benchmark, this is an 83% performance improvement at a cost of 9% more memory
-rw-r--r-- | src/cli/test_command.zig | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig index 8330a786b..3fdce584a 100644 --- a/src/cli/test_command.zig +++ b/src/cli/test_command.zig @@ -746,6 +746,7 @@ pub const TestCommand = struct { } const file_end = reporter.jest.files.len; + for (file_start..file_end) |module_id| { const module = reporter.jest.files.items(.module_scope)[module_id]; @@ -770,7 +771,15 @@ pub const TestCommand = struct { prev_unhandled_count = vm.unhandled_error_counter; } } - _ = vm.global.vm().runGC(false); + switch (vm.aggressive_garbage_collection) { + .none => {}, + .mild => { + _ = vm.global.vm().collectAsync(); + }, + .aggressive => { + _ = vm.global.vm().runGC(false); + }, + } } vm.global.vm().clearMicrotaskCallback(); |