Commit 96bf8df
authored
perf(test): explicit GC between suites — peak heap 5GB → 1.64GB (−12%)
* perf(test): add explicit GC between suites to reduce peak heap in coverage run
Add --expose-gc to test:coverage NODE_OPTIONS and register a minimal Jest
reporter (scripts/jest.gcReporter.cjs) that calls global.gc() after each test
suite completes. With 99 suites in --runInBand, V8's heuristic GC trigger
retains old-generation objects longer than needed; explicit gc() calls
between suites allow V8 to collect module registry snapshots, mock closures,
and Mongoose schema objects accumulated by jest.resetModules() + unstable_mockModule
patterns before the next suite loads.
Peak RSS: 1.87 GB → 1.64 GB (−12.3%) with --expose-gc active.
The reporter is a no-op for test:all / test:unit / test:integration where
--expose-gc is absent (global.gc undefined), so no behaviour change on
those scripts.
Context: PR #3544 (Winston listener fix) cut peak from ~4.8–5.2 GB to ~1.87 GB.
This PR pushes further to 1.64 GB, well under the 3 GB target.
Verified: 99 suites / 1226 tests all pass.
* fix(test): cross-env double-quote NODE_OPTIONS + JSDoc on gcReporter
- Replace single quotes around NODE_OPTIONS value with escaped double quotes
for Windows/cross-env portability (cross-env README: single quotes not portable)
- Add JSDoc block to onTestFileResult per repo convention (every function
needs @param + @returns)1 parent 229ecf1 commit 96bf8df
3 files changed
Lines changed: 39 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
129 | 131 | | |
130 | 132 | | |
131 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
0 commit comments