Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

runtime.ts

36 lines1.2 KB

1import { fileURLToPath } from 'node:url'
2import { isMemoryInstrumented } from './turn'
3​
4/** Worker settings for the CodSpeed memory instrument. */
5export function memoryExecArgv() {
6 if (!isMemoryInstrumented()) {
7 return []
8 }
9​
10 // CodSpeed supplies --no-opt, which only disables TurboFan on Node 24.
11 // Under --predictable, Maglev compilations run synchronously inside the
12 // request that triggers them, and the forced GC before the measured call can
13 // discard optimized code so recompiles land in the measured window. Their
14 // malloc'd Zone scratch (32 KiB segments) then dominates allocation metrics
15 // and depends on per-process feedback state.
16 // Limit variation from GC scheduling and bytecode reclamation; keep a
17 // fixed initial old-generation budget.
18 return [
19 '--no-maglev',
20 '--no-flush-bytecode',
21 '--no-minor-gc-task',
22 '--no-incremental-marking',
23 '--initial-old-space-size=512',
24 ]
26​
27export function memoryConfig(side: 'client' | 'server') {
28 const execArgv = memoryExecArgv()
29 return {
30 execArgv,
31 setupFiles:
32 side === 'client' || isMemoryInstrumented()
33 ? [fileURLToPath(new URL(`./${side}/vitest.setup.ts`, import.meta.url))]
34 : [],
35 }