Skip to content

Commit

Permalink
[bun:test] Don't schedule the GC aggressively on every file
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Jarred-Sumner committed May 23, 2023
1 parent de185bd commit f71eb39
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/cli/test_command.zig
Expand Up @@ -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];

Expand All @@ -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();
Expand Down

0 comments on commit f71eb39

Please sign in to comment.