diff --git a/.github/workflows/client-nav-benchmarks.yml b/.github/workflows/client-nav-benchmarks.yml index 7eedc222ae..2045a91a0b 100644 --- a/.github/workflows/client-nav-benchmarks.yml +++ b/.github/workflows/client-nav-benchmarks.yml @@ -20,6 +20,11 @@ on: - 'packages/**' - 'benchmarks/**' workflow_dispatch: + inputs: + memory-only: + description: Run only the memory benchmarks + type: boolean + default: false concurrency: group: client-nav-benchmarks-${{ github.ref }} @@ -45,20 +50,7 @@ jobs: - react - solid - vue - benchmark: - - client-nav - - ssr - - memory-server - - memory-client - include: - - benchmark: client-nav - mode: simulation - - benchmark: ssr - mode: simulation - - benchmark: memory-server - mode: memory - - benchmark: memory-client - mode: memory + benchmark: ${{ fromJSON(inputs.memory-only && '["memory-server", "memory-client"]' || '["client-nav", "ssr", "memory-server", "memory-client"]') }} runs-on: ubuntu-latest steps: - name: Checkout @@ -80,7 +72,7 @@ jobs: uses: CodSpeedHQ/action@4296e51e7041e24dadb86d1d6e8b9320d223dbe8 # v5.0.3 timeout-minutes: 20 with: - mode: ${{ matrix.mode }} + mode: ${{ startsWith(matrix.benchmark, 'memory-') && 'memory' || 'simulation' }} run: >- WITH_INSTRUMENTATION=1 pnpm nx run diff --git a/benchmarks/memory/client/scenarios/interrupted-navigations/react/vite.config.ts b/benchmarks/memory/client/scenarios/interrupted-navigations/react/vite.config.ts index 048a9cc833..5910981796 100644 --- a/benchmarks/memory/client/scenarios/interrupted-navigations/react/vite.config.ts +++ b/benchmarks/memory/client/scenarios/interrupted-navigations/react/vite.config.ts @@ -2,6 +2,7 @@ import { fileURLToPath } from 'node:url' import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import react from '@vitejs/plugin-react' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -26,6 +27,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client interrupted-navigations (react)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/interrupted-navigations/solid/vite.config.ts b/benchmarks/memory/client/scenarios/interrupted-navigations/solid/vite.config.ts index e710e0fd12..fbdfe6b8ea 100644 --- a/benchmarks/memory/client/scenarios/interrupted-navigations/solid/vite.config.ts +++ b/benchmarks/memory/client/scenarios/interrupted-navigations/solid/vite.config.ts @@ -2,6 +2,7 @@ import { fileURLToPath } from 'node:url' import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import solid from 'vite-plugin-solid' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -26,6 +27,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client interrupted-navigations (solid)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/interrupted-navigations/vue/vite.config.ts b/benchmarks/memory/client/scenarios/interrupted-navigations/vue/vite.config.ts index b2912ce9d1..a9814eace8 100644 --- a/benchmarks/memory/client/scenarios/interrupted-navigations/vue/vite.config.ts +++ b/benchmarks/memory/client/scenarios/interrupted-navigations/vue/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -28,6 +29,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client interrupted-navigations (vue)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/loader-data-retention/react/vite.config.ts b/benchmarks/memory/client/scenarios/loader-data-retention/react/vite.config.ts index 555e5f5612..e0e31c1fca 100644 --- a/benchmarks/memory/client/scenarios/loader-data-retention/react/vite.config.ts +++ b/benchmarks/memory/client/scenarios/loader-data-retention/react/vite.config.ts @@ -2,6 +2,7 @@ import { fileURLToPath } from 'node:url' import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import react from '@vitejs/plugin-react' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -26,6 +27,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client loader-data-retention (react)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/loader-data-retention/solid/vite.config.ts b/benchmarks/memory/client/scenarios/loader-data-retention/solid/vite.config.ts index 58d6b77acc..4011ff34ce 100644 --- a/benchmarks/memory/client/scenarios/loader-data-retention/solid/vite.config.ts +++ b/benchmarks/memory/client/scenarios/loader-data-retention/solid/vite.config.ts @@ -2,6 +2,7 @@ import { fileURLToPath } from 'node:url' import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import solid from 'vite-plugin-solid' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -26,6 +27,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client loader-data-retention (solid)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/loader-data-retention/vue/vite.config.ts b/benchmarks/memory/client/scenarios/loader-data-retention/vue/vite.config.ts index bbf2fd02d8..97c5bd726b 100644 --- a/benchmarks/memory/client/scenarios/loader-data-retention/vue/vite.config.ts +++ b/benchmarks/memory/client/scenarios/loader-data-retention/vue/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -28,6 +29,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client loader-data-retention (vue)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/mount-unmount/react/vite.config.ts b/benchmarks/memory/client/scenarios/mount-unmount/react/vite.config.ts index bb0f3c2e0a..020d1115c5 100644 --- a/benchmarks/memory/client/scenarios/mount-unmount/react/vite.config.ts +++ b/benchmarks/memory/client/scenarios/mount-unmount/react/vite.config.ts @@ -2,6 +2,7 @@ import { fileURLToPath } from 'node:url' import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import react from '@vitejs/plugin-react' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -26,6 +27,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client mount-unmount (react)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/mount-unmount/solid/vite.config.ts b/benchmarks/memory/client/scenarios/mount-unmount/solid/vite.config.ts index 5f0ab26252..94774af226 100644 --- a/benchmarks/memory/client/scenarios/mount-unmount/solid/vite.config.ts +++ b/benchmarks/memory/client/scenarios/mount-unmount/solid/vite.config.ts @@ -2,6 +2,7 @@ import { fileURLToPath } from 'node:url' import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import solid from 'vite-plugin-solid' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -26,6 +27,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client mount-unmount (solid)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/mount-unmount/vue/vite.config.ts b/benchmarks/memory/client/scenarios/mount-unmount/vue/vite.config.ts index 0f7573a408..d5ac1a6793 100644 --- a/benchmarks/memory/client/scenarios/mount-unmount/vue/vite.config.ts +++ b/benchmarks/memory/client/scenarios/mount-unmount/vue/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -28,6 +29,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client mount-unmount (vue)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/navigation-churn/react/vite.config.ts b/benchmarks/memory/client/scenarios/navigation-churn/react/vite.config.ts index b05b999297..d2881ea8ac 100644 --- a/benchmarks/memory/client/scenarios/navigation-churn/react/vite.config.ts +++ b/benchmarks/memory/client/scenarios/navigation-churn/react/vite.config.ts @@ -2,6 +2,7 @@ import { fileURLToPath } from 'node:url' import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import react from '@vitejs/plugin-react' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -26,6 +27,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client navigation-churn (react)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/navigation-churn/solid/vite.config.ts b/benchmarks/memory/client/scenarios/navigation-churn/solid/vite.config.ts index 6b6735891a..32b6b7b583 100644 --- a/benchmarks/memory/client/scenarios/navigation-churn/solid/vite.config.ts +++ b/benchmarks/memory/client/scenarios/navigation-churn/solid/vite.config.ts @@ -2,6 +2,7 @@ import { fileURLToPath } from 'node:url' import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import solid from 'vite-plugin-solid' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -26,6 +27,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client navigation-churn (solid)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/navigation-churn/vue/vite.config.ts b/benchmarks/memory/client/scenarios/navigation-churn/vue/vite.config.ts index d26ce23d07..defc633ff4 100644 --- a/benchmarks/memory/client/scenarios/navigation-churn/vue/vite.config.ts +++ b/benchmarks/memory/client/scenarios/navigation-churn/vue/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -28,6 +29,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client navigation-churn (vue)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/preload-churn/react/vite.config.ts b/benchmarks/memory/client/scenarios/preload-churn/react/vite.config.ts index f9c426656b..0d792a669a 100644 --- a/benchmarks/memory/client/scenarios/preload-churn/react/vite.config.ts +++ b/benchmarks/memory/client/scenarios/preload-churn/react/vite.config.ts @@ -2,6 +2,7 @@ import { fileURLToPath } from 'node:url' import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import react from '@vitejs/plugin-react' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -26,6 +27,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client preload-churn (react)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/preload-churn/solid/vite.config.ts b/benchmarks/memory/client/scenarios/preload-churn/solid/vite.config.ts index c86a6fcbb3..23fa994bd9 100644 --- a/benchmarks/memory/client/scenarios/preload-churn/solid/vite.config.ts +++ b/benchmarks/memory/client/scenarios/preload-churn/solid/vite.config.ts @@ -2,6 +2,7 @@ import { fileURLToPath } from 'node:url' import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import solid from 'vite-plugin-solid' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -26,6 +27,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client preload-churn (solid)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/preload-churn/vue/vite.config.ts b/benchmarks/memory/client/scenarios/preload-churn/vue/vite.config.ts index ea7ed7b695..a2d39c12de 100644 --- a/benchmarks/memory/client/scenarios/preload-churn/vue/vite.config.ts +++ b/benchmarks/memory/client/scenarios/preload-churn/vue/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -28,6 +29,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client preload-churn (vue)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/unique-location-churn/react/vite.config.ts b/benchmarks/memory/client/scenarios/unique-location-churn/react/vite.config.ts index f424c57cef..4d6359c2ab 100644 --- a/benchmarks/memory/client/scenarios/unique-location-churn/react/vite.config.ts +++ b/benchmarks/memory/client/scenarios/unique-location-churn/react/vite.config.ts @@ -2,6 +2,7 @@ import { fileURLToPath } from 'node:url' import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import react from '@vitejs/plugin-react' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -26,6 +27,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client unique-location-churn (react)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/unique-location-churn/solid/vite.config.ts b/benchmarks/memory/client/scenarios/unique-location-churn/solid/vite.config.ts index d4acf0019a..58abb71a63 100644 --- a/benchmarks/memory/client/scenarios/unique-location-churn/solid/vite.config.ts +++ b/benchmarks/memory/client/scenarios/unique-location-churn/solid/vite.config.ts @@ -2,6 +2,7 @@ import { fileURLToPath } from 'node:url' import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import solid from 'vite-plugin-solid' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -26,6 +27,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client unique-location-churn (solid)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/client/scenarios/unique-location-churn/vue/vite.config.ts b/benchmarks/memory/client/scenarios/unique-location-churn/vue/vite.config.ts index 423126019b..edcfd3fa10 100644 --- a/benchmarks/memory/client/scenarios/unique-location-churn/vue/vite.config.ts +++ b/benchmarks/memory/client/scenarios/unique-location-churn/vue/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -28,6 +29,7 @@ export default defineConfig({ }, }, test: { + execArgv: memoryExecArgv(), name: '@benchmarks/memory-client unique-location-churn (vue)', watch: false, environment: 'jsdom', diff --git a/benchmarks/memory/runtime.ts b/benchmarks/memory/runtime.ts new file mode 100644 index 0000000000..941de2dfe5 --- /dev/null +++ b/benchmarks/memory/runtime.ts @@ -0,0 +1,18 @@ +/** Worker settings for the CodSpeed memory instrument. */ +export function memoryExecArgv() { + if ( + process.env.CODSPEED_ENV === undefined || + process.env.CODSPEED_RUNNER_MODE !== 'memory' + ) { + return [] + } + + // Node 24 still enables Maglev under CodSpeed's --no-opt. Compile baseline + // code eagerly and keep minor GC tied to allocations instead of tasks. + return [ + '--no-maglev', + '--always-sparkplug', + '--no-minor-gc-task', + '--initial-old-space-size=512', + ] +} diff --git a/benchmarks/memory/server/bench-utils.test.ts b/benchmarks/memory/server/bench-utils.test.ts new file mode 100644 index 0000000000..6ea717ae24 --- /dev/null +++ b/benchmarks/memory/server/bench-utils.test.ts @@ -0,0 +1,62 @@ +import { afterEach, expect, it, vi } from 'vitest' +import { runSequentialRequestLoop } from './bench-utils' + +afterEach(() => { + vi.useRealTimers() + vi.unstubAllGlobals() +}) + +it('drains each response before starting the next request', async () => { + vi.useFakeTimers() + const events: Array = [] + let index = 0 + const run = runSequentialRequestLoop( + { + fetch() { + const current = index++ + events.push(`fetch ${current}`) + return new Response( + new ReadableStream({ + start(controller) { + setTimeout(() => { + events.push(`body ${current}`) + controller.enqueue(new Uint8Array([1])) + controller.close() + }, 0) + }, + }), + ) + }, + }, + { + seed: 1, + iterations: 2, + buildRequest: () => new Request('http://localhost/'), + }, + ) + await vi.runAllTimersAsync() + await run + expect(events).toEqual(['fetch 0', 'body 0', 'fetch 1', 'body 1']) +}) + +it('releases a failed response reader and does not start another request', async () => { + const failure = new Error('stream failed') + const body = new ReadableStream({ + start(controller) { + controller.error(failure) + }, + }) + const fetch = vi.fn(() => new Response(body)) + await expect( + runSequentialRequestLoop( + { fetch }, + { + seed: 1, + iterations: 2, + buildRequest: () => new Request('http://localhost/'), + }, + ), + ).rejects.toBe(failure) + expect(body.locked).toBe(false) + expect(fetch).toHaveBeenCalledTimes(1) +}) diff --git a/benchmarks/memory/server/bench-utils.ts b/benchmarks/memory/server/bench-utils.ts index b8a09fdd8e..8893d5be4b 100644 --- a/benchmarks/memory/server/bench-utils.ts +++ b/benchmarks/memory/server/bench-utils.ts @@ -17,24 +17,6 @@ export type RunSequentialRequestLoopOptions = iterations?: number buildRequest: (random: () => number, index: number) => Request validateResponse?: (response: Response, request: Request) => void - // Whether V8 collects iteration i's garbage before iteration i+1 - // allocates its payload is not reproducible run to run — the measured - // peak flips by a whole payload depending on GC timing, which shifts - // with runner hardware. Forcing a collection between iterations pins - // the GC points so peak deterministically measures the largest - // single-iteration footprint plus any reachable accumulation. - // Accumulation signals stay visible: leaked or cached objects are - // still referenced, so a forced collection cannot reclaim them — it - // only removes floating garbage, whose collection timing is the - // dominant cross-run noise source. - pinGcBetweenIterations?: boolean - // For peak-shape scenarios ONLY (flat inter-iteration heap floor): - // verify each pinned collection actually returned the heap to the - // floor, extending the barrier when a runner's late teardown holds the - // payload past the fixed window. Churn/abort scenarios must not set - // this: their floor legitimately drifts, so the verification caps out - // chronically and the extra collections it fires destabilize the peak. - verifyGcFloor?: boolean } export const memoryBenchOptions = { @@ -66,7 +48,7 @@ export async function drainResponse(response: Response) { } try { - while (true) { + for (;;) { const result = await reader.read() if (result.done) { @@ -82,13 +64,7 @@ export async function runSequentialRequestLoop( handler: StartRequestHandler, options: RunSequentialRequestLoopOptions, ) { - const { - iterations = 10, - buildRequest, - validateResponse, - pinGcBetweenIterations = false, - verifyGcFloor = false, - } = options + const { iterations = 10, buildRequest, validateResponse } = options const random = options.seed !== undefined ? createDeterministicRandom(options.seed) @@ -103,8 +79,6 @@ export async function runSequentialRequestLoop( } }) - const gcPinState = verifyGcFloor ? createGcPinState() : undefined - for (let index = 0; index < iterations; index++) { const request = buildRequest(random, index) const response = await handler.fetch(request) @@ -112,89 +86,12 @@ export async function runSequentialRequestLoop( validate(response, request) await drainResponse(response) - - if (pinGcBetweenIterations) { - await settleAndPinGc(gcPinState) - } } } -// Renderer/stream teardown spans several event-loop turns (React and Vue -// need more than the two turns the original barrier allowed for), and a -// too-short settle window leaks a whole payload of garbage past the -// collection point, flipping the measured peak bimodally between runs. -// The settle length is a fixed count on purpose: an adaptive exit (collect -// until the post-GC heap size stops moving) makes the collection points -// land at data-dependent turns, which re-introduces exactly the run-to-run -// variance this barrier exists to remove — heap-size readings never fully -// stabilize under the instrumented CI environment, so the exit point (and -// with it every subsequent GC point) shifted between identical runs. -const settleTurnsBeforeGc = 16 -const maxSettleTurns = 64 -// Below every scenario's payload size, above normal inter-iteration jitter. -const settledHeapSlackBytes = 256 * 1024 - -// Tracks the smallest post-collection heap size seen in a workload run: -// the inter-iteration floor the heap must return to before the next -// iteration may start. -export interface GcPinState { - floorHeapUsed: number -} - -export function createGcPinState(): GcPinState { - return { floorHeapUsed: Infinity } -} - -// Settle trailing renderer/stream teardown with a fixed number of 0ms timer -// hops (one full event-loop turn each, microtasks flushing between hops), -// then pin a collection point. The second collection one turn later picks -// up whatever the first collection's finalizers released. gc() is present -// under CodSpeed (--expose-gc); in plain smoke runs there is nothing to -// pin, so only the settle hops run. -// -// The collection is then verified against the inter-iteration heap floor: -// on some runners the response teardown holds the payload past the fixed -// settle window (released only by a later internal timer), and that one -// still-reachable payload survives the collection and bleeds into the next -// iteration's measured peak. When the post-collection heap has not returned -// to the floor, keep hopping and collecting — bounded — until the payload -// is actually released, so the barrier self-heals in exactly the case where -// the fixed-count barrier fails. A workload that genuinely accumulates -// reachable memory raises the floor as it goes (the floor is the minimum -// seen), so accumulation still measures; it only pays the turn cap. -export async function settleAndPinGc(state?: GcPinState) { - for (let turn = 0; turn < settleTurnsBeforeGc; turn++) { +// Cancellation can leave deferred loaders and renderer teardown queued. +export async function settle() { + for (let turn = 0; turn < 16; turn++) { await new Promise((resolve) => setTimeout(resolve, 0)) } - - const gc = (globalThis as { gc?: () => void }).gc - - if (!gc) { - return - } - - gc() - await new Promise((resolve) => setTimeout(resolve, 0)) - gc() - - if (!state) { - return - } - - let heapUsed = process.memoryUsage().heapUsed - - for ( - let turn = settleTurnsBeforeGc; - turn < maxSettleTurns && - heapUsed > state.floorHeapUsed + settledHeapSlackBytes; - turn++ - ) { - await new Promise((resolve) => setTimeout(resolve, 0)) - gc() - heapUsed = process.memoryUsage().heapUsed - } - - if (heapUsed < state.floorHeapUsed) { - state.floorHeapUsed = heapUsed - } } diff --git a/benchmarks/memory/server/package.json b/benchmarks/memory/server/package.json index 423dde0eb3..b3774a2778 100644 --- a/benchmarks/memory/server/package.json +++ b/benchmarks/memory/server/package.json @@ -237,7 +237,7 @@ } }, "test:types": { - "executor": "nx:noop", + "executor": "nx:run-commands", "dependsOn": [ { "projects": [ @@ -265,6 +265,22 @@ ], "target": "test:types:ssr" } + ], + "options": { + "command": "tsc -p ./tsconfig.json --noEmit", + "cwd": "benchmarks/memory/server" + } + }, + "test:unit": { + "executor": "nx:run-commands", + "options": { + "command": "vitest run --config ./vitest.unit.config.ts", + "cwd": "benchmarks/memory/server" + }, + "inputs": [ + "default", + "^production", + "{workspaceRoot}/benchmarks/memory/runtime.ts" ] } } diff --git a/benchmarks/memory/server/runtime.test.ts b/benchmarks/memory/server/runtime.test.ts new file mode 100644 index 0000000000..d4bcccd745 --- /dev/null +++ b/benchmarks/memory/server/runtime.test.ts @@ -0,0 +1,62 @@ +import { execFileSync } from 'node:child_process' +import { afterEach, describe, expect, it, vi } from 'vitest' +import { resolveConfig } from 'vite' +import codspeedPlugin from '@codspeed/vitest-plugin' +import { memoryExecArgv } from '../runtime' + +afterEach(() => { + vi.unstubAllEnvs() +}) + +describe('memory worker configuration', () => { + it('preserves CodSpeed instrumentation flags in a runnable worker', async () => { + vi.stubEnv('CODSPEED_ENV', 'test') + vi.stubEnv('CODSPEED_RUNNER_MODE', 'memory') + + const config = await resolveConfig( + { + configFile: false, + plugins: [codspeedPlugin()], + test: { execArgv: memoryExecArgv() }, + }, + 'serve', + 'benchmark', + ) + const flags = config.test!.execArgv! + expect(flags).toContain('--expose-gc') + expect(flags).toContain('--predictable') + expect(flags).toContain('--hash-seed=1') + + const output = execFileSync( + process.execPath, + [ + ...flags, + '--trace-opt', + '--eval', + ` + if (typeof global.gc !== 'function') { + throw new Error('Missing GC instrumentation') + } + function hot(value) { return value + 1 } + let total = 0 + for (let index = 0; index < 100000; index++) { + total += hot(index) + } + console.log(total) + `, + ], + { encoding: 'utf8' }, + ) + expect(output).toContain('5000050000') + expect(output).not.toMatch(/MAGLEV/) + }) + + it.each([undefined, 'simulation', 'instrumentation', 'walltime'])( + 'does not change %s workers', + (mode) => { + vi.stubEnv('CODSPEED_ENV', 'test') + vi.stubEnv('CODSPEED_RUNNER_MODE', mode) + expect(memoryExecArgv()).toEqual([]) + }, + ) +}) diff --git a/benchmarks/memory/server/scenarios/aborted-requests/react/vite.config.ts b/benchmarks/memory/server/scenarios/aborted-requests/react/vite.config.ts index 2ce925e406..7a0d8ea3a1 100644 --- a/benchmarks/memory/server/scenarios/aborted-requests/react/vite.config.ts +++ b/benchmarks/memory/server/scenarios/aborted-requests/react/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/react-start/plugin/vite' import react from '@vitejs/plugin-react' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/aborted-requests/shared.ts b/benchmarks/memory/server/scenarios/aborted-requests/shared.ts index c98f462538..dfd064cd63 100644 --- a/benchmarks/memory/server/scenarios/aborted-requests/shared.ts +++ b/benchmarks/memory/server/scenarios/aborted-requests/shared.ts @@ -1,4 +1,4 @@ -import { settleAndPinGc } from '#memory-server/bench-utils' +import { settle } from '#memory-server/bench-utils' import type { StartRequestHandler } from '#memory-server/bench-utils' export type { StartRequestHandler } @@ -96,7 +96,7 @@ async function readShellBeforeDeferred( const reader = response.body.getReader() let text = '' - while (true) { + for (;;) { const result = await reader.read() const value = result.value @@ -184,12 +184,9 @@ async function cancelReader( await reader.cancel() } -// Post-abort settlement barrier. Settles renderer teardown across a fixed -// number of event-loop turns, then (under CodSpeed) pins a collection point -// after every aborted request, so the measured peak cannot drift with how -// much floating garbage the previous iterations happened to leave behind. +// Let deferred loaders and renderer teardown finish after cancellation. async function drainCancellation() { - await settleAndPinGc() + await settle() } async function assertAbortedRequestsSanity( diff --git a/benchmarks/memory/server/scenarios/aborted-requests/solid/vite.config.ts b/benchmarks/memory/server/scenarios/aborted-requests/solid/vite.config.ts index 5ee4e152af..6729a10f5b 100644 --- a/benchmarks/memory/server/scenarios/aborted-requests/solid/vite.config.ts +++ b/benchmarks/memory/server/scenarios/aborted-requests/solid/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/solid-start/plugin/vite' import solid from 'vite-plugin-solid' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/aborted-requests/vue/vite.config.ts b/benchmarks/memory/server/scenarios/aborted-requests/vue/vite.config.ts index 5ccc9f5d1d..011e60e6a8 100644 --- a/benchmarks/memory/server/scenarios/aborted-requests/vue/vite.config.ts +++ b/benchmarks/memory/server/scenarios/aborted-requests/vue/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/vue-start/plugin/vite' import vueJsx from '@vitejs/plugin-vue-jsx' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/error-paths/react/memory.bench.ts b/benchmarks/memory/server/scenarios/error-paths/react/memory.bench.ts index 9a5c211fee..2780830cb2 100644 --- a/benchmarks/memory/server/scenarios/error-paths/react/memory.bench.ts +++ b/benchmarks/memory/server/scenarios/error-paths/react/memory.bench.ts @@ -4,8 +4,8 @@ import { workloadGroup } from './setup' await workloadGroup.sanity() +const workload = workloadGroup.workloads[0]! + describe('memory', () => { - for (const workload of workloadGroup.workloads) { - bench(workload.name, workload.run, memoryBenchOptions) - } + bench(workload.name, workload.run, memoryBenchOptions) }) diff --git a/benchmarks/memory/server/scenarios/error-paths/react/memory.error.bench.ts b/benchmarks/memory/server/scenarios/error-paths/react/memory.error.bench.ts new file mode 100644 index 0000000000..d41877e6ce --- /dev/null +++ b/benchmarks/memory/server/scenarios/error-paths/react/memory.error.bench.ts @@ -0,0 +1,11 @@ +import { bench, describe } from 'vitest' +import { memoryBenchOptions } from '#memory-server/bench-utils' +import { workloadGroup } from './setup' + +await workloadGroup.sanity() + +const workload = workloadGroup.workloads[2]! + +describe('memory', () => { + bench(workload.name, workload.run, memoryBenchOptions) +}) diff --git a/benchmarks/memory/server/scenarios/error-paths/react/memory.not-found.bench.ts b/benchmarks/memory/server/scenarios/error-paths/react/memory.not-found.bench.ts new file mode 100644 index 0000000000..42d67b1164 --- /dev/null +++ b/benchmarks/memory/server/scenarios/error-paths/react/memory.not-found.bench.ts @@ -0,0 +1,11 @@ +import { bench, describe } from 'vitest' +import { memoryBenchOptions } from '#memory-server/bench-utils' +import { workloadGroup } from './setup' + +await workloadGroup.sanity() + +const workload = workloadGroup.workloads[1]! + +describe('memory', () => { + bench(workload.name, workload.run, memoryBenchOptions) +}) diff --git a/benchmarks/memory/server/scenarios/error-paths/react/memory.unmatched.bench.ts b/benchmarks/memory/server/scenarios/error-paths/react/memory.unmatched.bench.ts new file mode 100644 index 0000000000..6179e469dd --- /dev/null +++ b/benchmarks/memory/server/scenarios/error-paths/react/memory.unmatched.bench.ts @@ -0,0 +1,11 @@ +import { bench, describe } from 'vitest' +import { memoryBenchOptions } from '#memory-server/bench-utils' +import { workloadGroup } from './setup' + +await workloadGroup.sanity() + +const workload = workloadGroup.workloads[3]! + +describe('memory', () => { + bench(workload.name, workload.run, memoryBenchOptions) +}) diff --git a/benchmarks/memory/server/scenarios/error-paths/react/tsconfig.json b/benchmarks/memory/server/scenarios/error-paths/react/tsconfig.json index 11ddcce4ea..2dba47fc99 100644 --- a/benchmarks/memory/server/scenarios/error-paths/react/tsconfig.json +++ b/benchmarks/memory/server/scenarios/error-paths/react/tsconfig.json @@ -7,7 +7,7 @@ "types": ["node", "vite/client", "vitest/globals"] }, "include": [ - "memory.bench.ts", + "memory*.bench.ts", "memory.flame.ts", "setup.ts", "vite.config.ts", diff --git a/benchmarks/memory/server/scenarios/error-paths/react/vite.config.ts b/benchmarks/memory/server/scenarios/error-paths/react/vite.config.ts index bc67b1cfc7..f1e6b78c30 100644 --- a/benchmarks/memory/server/scenarios/error-paths/react/vite.config.ts +++ b/benchmarks/memory/server/scenarios/error-paths/react/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/react-start/plugin/vite' import react from '@vitejs/plugin-react' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -22,16 +23,14 @@ export default defineConfig({ minify: false, }, test: { + isolate: true, // Keep lazily-compiled code alive for the whole run: the pinned // collections age code fast enough for V8 to flush unused bytecode, // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/error-paths/shared.ts b/benchmarks/memory/server/scenarios/error-paths/shared.ts index 57e229b7e3..966505f3a0 100644 --- a/benchmarks/memory/server/scenarios/error-paths/shared.ts +++ b/benchmarks/memory/server/scenarios/error-paths/shared.ts @@ -9,8 +9,6 @@ export type { StartRequestHandler } type Framework = 'react' | 'solid' | 'vue' -// Sized to sit just above the 2s measured-run floor on CI (per-iteration -// cost with the pinned collection is ~0.13-0.19s across frameworks). const errorPathsIterations = 18 const redirectSeed = 0xdecafbad const notFoundSeed = 0xdecafb0d @@ -144,7 +142,6 @@ export function createWorkloadGroup( iterations: errorPathsIterations, buildRequest: buildRedirectRequest, validateResponse: validateRedirectResponse, - pinGcBetweenIterations: true, }) const runNotFound = () => @@ -153,7 +150,6 @@ export function createWorkloadGroup( iterations: errorPathsIterations, buildRequest: buildNotFoundRequest, validateResponse: validateNotFoundResponse, - pinGcBetweenIterations: true, }) const runError = () => @@ -162,7 +158,6 @@ export function createWorkloadGroup( iterations: errorPathsIterations, buildRequest: buildErrorRequest, validateResponse: validateErrorResponse, - pinGcBetweenIterations: true, }) const runUnmatched = () => @@ -171,7 +166,6 @@ export function createWorkloadGroup( iterations: errorPathsIterations, buildRequest: buildUnmatchedRequest, validateResponse: validateNotFoundResponse, - pinGcBetweenIterations: true, }) return { diff --git a/benchmarks/memory/server/scenarios/error-paths/solid/memory.bench.ts b/benchmarks/memory/server/scenarios/error-paths/solid/memory.bench.ts index 9a5c211fee..2780830cb2 100644 --- a/benchmarks/memory/server/scenarios/error-paths/solid/memory.bench.ts +++ b/benchmarks/memory/server/scenarios/error-paths/solid/memory.bench.ts @@ -4,8 +4,8 @@ import { workloadGroup } from './setup' await workloadGroup.sanity() +const workload = workloadGroup.workloads[0]! + describe('memory', () => { - for (const workload of workloadGroup.workloads) { - bench(workload.name, workload.run, memoryBenchOptions) - } + bench(workload.name, workload.run, memoryBenchOptions) }) diff --git a/benchmarks/memory/server/scenarios/error-paths/solid/memory.error.bench.ts b/benchmarks/memory/server/scenarios/error-paths/solid/memory.error.bench.ts new file mode 100644 index 0000000000..d41877e6ce --- /dev/null +++ b/benchmarks/memory/server/scenarios/error-paths/solid/memory.error.bench.ts @@ -0,0 +1,11 @@ +import { bench, describe } from 'vitest' +import { memoryBenchOptions } from '#memory-server/bench-utils' +import { workloadGroup } from './setup' + +await workloadGroup.sanity() + +const workload = workloadGroup.workloads[2]! + +describe('memory', () => { + bench(workload.name, workload.run, memoryBenchOptions) +}) diff --git a/benchmarks/memory/server/scenarios/error-paths/solid/memory.not-found.bench.ts b/benchmarks/memory/server/scenarios/error-paths/solid/memory.not-found.bench.ts new file mode 100644 index 0000000000..42d67b1164 --- /dev/null +++ b/benchmarks/memory/server/scenarios/error-paths/solid/memory.not-found.bench.ts @@ -0,0 +1,11 @@ +import { bench, describe } from 'vitest' +import { memoryBenchOptions } from '#memory-server/bench-utils' +import { workloadGroup } from './setup' + +await workloadGroup.sanity() + +const workload = workloadGroup.workloads[1]! + +describe('memory', () => { + bench(workload.name, workload.run, memoryBenchOptions) +}) diff --git a/benchmarks/memory/server/scenarios/error-paths/solid/memory.unmatched.bench.ts b/benchmarks/memory/server/scenarios/error-paths/solid/memory.unmatched.bench.ts new file mode 100644 index 0000000000..6179e469dd --- /dev/null +++ b/benchmarks/memory/server/scenarios/error-paths/solid/memory.unmatched.bench.ts @@ -0,0 +1,11 @@ +import { bench, describe } from 'vitest' +import { memoryBenchOptions } from '#memory-server/bench-utils' +import { workloadGroup } from './setup' + +await workloadGroup.sanity() + +const workload = workloadGroup.workloads[3]! + +describe('memory', () => { + bench(workload.name, workload.run, memoryBenchOptions) +}) diff --git a/benchmarks/memory/server/scenarios/error-paths/solid/tsconfig.json b/benchmarks/memory/server/scenarios/error-paths/solid/tsconfig.json index 4b61264e11..1e8103127a 100644 --- a/benchmarks/memory/server/scenarios/error-paths/solid/tsconfig.json +++ b/benchmarks/memory/server/scenarios/error-paths/solid/tsconfig.json @@ -7,7 +7,7 @@ "types": ["node", "vite/client", "vitest/globals"] }, "include": [ - "memory.bench.ts", + "memory*.bench.ts", "memory.flame.ts", "setup.ts", "vite.config.ts", diff --git a/benchmarks/memory/server/scenarios/error-paths/solid/vite.config.ts b/benchmarks/memory/server/scenarios/error-paths/solid/vite.config.ts index 401d1e5f25..7e7c59b1d5 100644 --- a/benchmarks/memory/server/scenarios/error-paths/solid/vite.config.ts +++ b/benchmarks/memory/server/scenarios/error-paths/solid/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/solid-start/plugin/vite' import solid from 'vite-plugin-solid' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -22,16 +23,14 @@ export default defineConfig({ minify: false, }, test: { + isolate: true, // Keep lazily-compiled code alive for the whole run: the pinned // collections age code fast enough for V8 to flush unused bytecode, // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/error-paths/vue/memory.bench.ts b/benchmarks/memory/server/scenarios/error-paths/vue/memory.bench.ts index 9a5c211fee..2780830cb2 100644 --- a/benchmarks/memory/server/scenarios/error-paths/vue/memory.bench.ts +++ b/benchmarks/memory/server/scenarios/error-paths/vue/memory.bench.ts @@ -4,8 +4,8 @@ import { workloadGroup } from './setup' await workloadGroup.sanity() +const workload = workloadGroup.workloads[0]! + describe('memory', () => { - for (const workload of workloadGroup.workloads) { - bench(workload.name, workload.run, memoryBenchOptions) - } + bench(workload.name, workload.run, memoryBenchOptions) }) diff --git a/benchmarks/memory/server/scenarios/error-paths/vue/memory.error.bench.ts b/benchmarks/memory/server/scenarios/error-paths/vue/memory.error.bench.ts new file mode 100644 index 0000000000..d41877e6ce --- /dev/null +++ b/benchmarks/memory/server/scenarios/error-paths/vue/memory.error.bench.ts @@ -0,0 +1,11 @@ +import { bench, describe } from 'vitest' +import { memoryBenchOptions } from '#memory-server/bench-utils' +import { workloadGroup } from './setup' + +await workloadGroup.sanity() + +const workload = workloadGroup.workloads[2]! + +describe('memory', () => { + bench(workload.name, workload.run, memoryBenchOptions) +}) diff --git a/benchmarks/memory/server/scenarios/error-paths/vue/memory.not-found.bench.ts b/benchmarks/memory/server/scenarios/error-paths/vue/memory.not-found.bench.ts new file mode 100644 index 0000000000..42d67b1164 --- /dev/null +++ b/benchmarks/memory/server/scenarios/error-paths/vue/memory.not-found.bench.ts @@ -0,0 +1,11 @@ +import { bench, describe } from 'vitest' +import { memoryBenchOptions } from '#memory-server/bench-utils' +import { workloadGroup } from './setup' + +await workloadGroup.sanity() + +const workload = workloadGroup.workloads[1]! + +describe('memory', () => { + bench(workload.name, workload.run, memoryBenchOptions) +}) diff --git a/benchmarks/memory/server/scenarios/error-paths/vue/memory.unmatched.bench.ts b/benchmarks/memory/server/scenarios/error-paths/vue/memory.unmatched.bench.ts new file mode 100644 index 0000000000..6179e469dd --- /dev/null +++ b/benchmarks/memory/server/scenarios/error-paths/vue/memory.unmatched.bench.ts @@ -0,0 +1,11 @@ +import { bench, describe } from 'vitest' +import { memoryBenchOptions } from '#memory-server/bench-utils' +import { workloadGroup } from './setup' + +await workloadGroup.sanity() + +const workload = workloadGroup.workloads[3]! + +describe('memory', () => { + bench(workload.name, workload.run, memoryBenchOptions) +}) diff --git a/benchmarks/memory/server/scenarios/error-paths/vue/tsconfig.json b/benchmarks/memory/server/scenarios/error-paths/vue/tsconfig.json index 9ad6481342..af8b83005c 100644 --- a/benchmarks/memory/server/scenarios/error-paths/vue/tsconfig.json +++ b/benchmarks/memory/server/scenarios/error-paths/vue/tsconfig.json @@ -7,7 +7,7 @@ "types": ["node", "vite/client", "vitest/globals"] }, "include": [ - "memory.bench.ts", + "memory*.bench.ts", "memory.flame.ts", "setup.ts", "vite.config.ts", diff --git a/benchmarks/memory/server/scenarios/error-paths/vue/vite.config.ts b/benchmarks/memory/server/scenarios/error-paths/vue/vite.config.ts index 9a0ca28a25..fc43376502 100644 --- a/benchmarks/memory/server/scenarios/error-paths/vue/vite.config.ts +++ b/benchmarks/memory/server/scenarios/error-paths/vue/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/vue-start/plugin/vite' import vueJsx from '@vitejs/plugin-vue-jsx' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -22,16 +23,14 @@ export default defineConfig({ minify: false, }, test: { + isolate: true, // Keep lazily-compiled code alive for the whole run: the pinned // collections age code fast enough for V8 to flush unused bytecode, // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/peak-large-page/react/vite.config.ts b/benchmarks/memory/server/scenarios/peak-large-page/react/vite.config.ts index adaacda86e..202b646c03 100644 --- a/benchmarks/memory/server/scenarios/peak-large-page/react/vite.config.ts +++ b/benchmarks/memory/server/scenarios/peak-large-page/react/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/react-start/plugin/vite' import react from '@vitejs/plugin-react' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/peak-large-page/shared.ts b/benchmarks/memory/server/scenarios/peak-large-page/shared.ts index 578fc9c5a2..486c025f5a 100644 --- a/benchmarks/memory/server/scenarios/peak-large-page/shared.ts +++ b/benchmarks/memory/server/scenarios/peak-large-page/shared.ts @@ -6,7 +6,7 @@ export type { StartRequestHandler } type Framework = 'react' | 'solid' | 'vue' const benchmarkSeed = 0x5eed_0005 -const peakLargePageIterations = 20 +const peakLargePageIterations = 1 const peakLargePageUrl = 'http://localhost/l1/l2/l3/l4/l5/l6/l7/l8' const levelEightMarker = 'data-bench="peak-large-page-level-8"' @@ -54,8 +54,6 @@ export function createWorkloadGroup( iterations: peakLargePageIterations, buildRequest: buildPeakLargePageRequest, validateResponse: validatePeakLargePageResponse, - pinGcBetweenIterations: true, - verifyGcFloor: true, }) return { diff --git a/benchmarks/memory/server/scenarios/peak-large-page/solid/vite.config.ts b/benchmarks/memory/server/scenarios/peak-large-page/solid/vite.config.ts index 27d4dd65f7..6cf1cfd56d 100644 --- a/benchmarks/memory/server/scenarios/peak-large-page/solid/vite.config.ts +++ b/benchmarks/memory/server/scenarios/peak-large-page/solid/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/solid-start/plugin/vite' import solid from 'vite-plugin-solid' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/peak-large-page/vue/vite.config.ts b/benchmarks/memory/server/scenarios/peak-large-page/vue/vite.config.ts index 0f238bd7f7..8e18d805ed 100644 --- a/benchmarks/memory/server/scenarios/peak-large-page/vue/vite.config.ts +++ b/benchmarks/memory/server/scenarios/peak-large-page/vue/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/vue-start/plugin/vite' import vueJsx from '@vitejs/plugin-vue-jsx' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/request-churn/react/vite.config.ts b/benchmarks/memory/server/scenarios/request-churn/react/vite.config.ts index 1e956958ec..e29fac4fe9 100644 --- a/benchmarks/memory/server/scenarios/request-churn/react/vite.config.ts +++ b/benchmarks/memory/server/scenarios/request-churn/react/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/react-start/plugin/vite' import react from '@vitejs/plugin-react' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/request-churn/shared.ts b/benchmarks/memory/server/scenarios/request-churn/shared.ts index a196eec8b5..32125148cd 100644 --- a/benchmarks/memory/server/scenarios/request-churn/shared.ts +++ b/benchmarks/memory/server/scenarios/request-churn/shared.ts @@ -68,7 +68,6 @@ export function createWorkloadGroup( iterations: requestChurnIterations, buildRequest: buildItemRequest, validateResponse: validateItemResponse, - pinGcBetweenIterations: true, }) return { diff --git a/benchmarks/memory/server/scenarios/request-churn/solid/vite.config.ts b/benchmarks/memory/server/scenarios/request-churn/solid/vite.config.ts index fbf8df9491..6f66d036d1 100644 --- a/benchmarks/memory/server/scenarios/request-churn/solid/vite.config.ts +++ b/benchmarks/memory/server/scenarios/request-churn/solid/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/solid-start/plugin/vite' import solid from 'vite-plugin-solid' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/request-churn/vue/vite.config.ts b/benchmarks/memory/server/scenarios/request-churn/vue/vite.config.ts index a551a96e2f..7bb96efffa 100644 --- a/benchmarks/memory/server/scenarios/request-churn/vue/vite.config.ts +++ b/benchmarks/memory/server/scenarios/request-churn/vue/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/vue-start/plugin/vite' import vueJsx from '@vitejs/plugin-vue-jsx' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/serialization-payload/react/vite.config.ts b/benchmarks/memory/server/scenarios/serialization-payload/react/vite.config.ts index de5549de3b..ea8783aa79 100644 --- a/benchmarks/memory/server/scenarios/serialization-payload/react/vite.config.ts +++ b/benchmarks/memory/server/scenarios/serialization-payload/react/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/react-start/plugin/vite' import react from '@vitejs/plugin-react' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/serialization-payload/shared.ts b/benchmarks/memory/server/scenarios/serialization-payload/shared.ts index ce095b5e10..7f40aeb9d2 100644 --- a/benchmarks/memory/server/scenarios/serialization-payload/shared.ts +++ b/benchmarks/memory/server/scenarios/serialization-payload/shared.ts @@ -9,7 +9,7 @@ export type { StartRequestHandler } type Framework = 'react' | 'solid' | 'vue' const benchmarkSeed = 0x51eaa11 -const serializationPayloadIterations = 12 +const serializationPayloadIterations = 1 const payloadPageMarker = 'data-bench="serialization-payload"' const requestInit = { @@ -61,8 +61,6 @@ export function createWorkloadGroup( iterations: serializationPayloadIterations, buildRequest: buildPayloadRequest, validateResponse: validatePayloadResponse, - pinGcBetweenIterations: true, - verifyGcFloor: true, }) return { diff --git a/benchmarks/memory/server/scenarios/serialization-payload/solid/vite.config.ts b/benchmarks/memory/server/scenarios/serialization-payload/solid/vite.config.ts index 926646ee12..2d26f8c74a 100644 --- a/benchmarks/memory/server/scenarios/serialization-payload/solid/vite.config.ts +++ b/benchmarks/memory/server/scenarios/serialization-payload/solid/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/solid-start/plugin/vite' import solid from 'vite-plugin-solid' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/serialization-payload/vue/vite.config.ts b/benchmarks/memory/server/scenarios/serialization-payload/vue/vite.config.ts index 41a5596adf..f7884525ad 100644 --- a/benchmarks/memory/server/scenarios/serialization-payload/vue/vite.config.ts +++ b/benchmarks/memory/server/scenarios/serialization-payload/vue/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/vue-start/plugin/vite' import vueJsx from '@vitejs/plugin-vue-jsx' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/server-fn-churn/react/vite.config.ts b/benchmarks/memory/server/scenarios/server-fn-churn/react/vite.config.ts index 68d9ed839b..5fa9cfbb82 100644 --- a/benchmarks/memory/server/scenarios/server-fn-churn/react/vite.config.ts +++ b/benchmarks/memory/server/scenarios/server-fn-churn/react/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/react-start/plugin/vite' import react from '@vitejs/plugin-react' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/server-fn-churn/shared.ts b/benchmarks/memory/server/scenarios/server-fn-churn/shared.ts index 6e2959e757..2bc224c979 100644 --- a/benchmarks/memory/server/scenarios/server-fn-churn/shared.ts +++ b/benchmarks/memory/server/scenarios/server-fn-churn/shared.ts @@ -208,7 +208,6 @@ export async function createWorkloadGroup( runSequentialRequestLoop(handler, { seed: benchmarkSeed, iterations: serverFnChurnIterations, - pinGcBetweenIterations: true, buildRequest: (_random, index) => { const fixtureIndex = Math.floor(index / 2) % fixtureCount diff --git a/benchmarks/memory/server/scenarios/server-fn-churn/solid/vite.config.ts b/benchmarks/memory/server/scenarios/server-fn-churn/solid/vite.config.ts index 8d6d226e97..233d3ef5a3 100644 --- a/benchmarks/memory/server/scenarios/server-fn-churn/solid/vite.config.ts +++ b/benchmarks/memory/server/scenarios/server-fn-churn/solid/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/solid-start/plugin/vite' import solid from 'vite-plugin-solid' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/server-fn-churn/vue/vite.config.ts b/benchmarks/memory/server/scenarios/server-fn-churn/vue/vite.config.ts index 0e249b9f3b..c264768167 100644 --- a/benchmarks/memory/server/scenarios/server-fn-churn/vue/vite.config.ts +++ b/benchmarks/memory/server/scenarios/server-fn-churn/vue/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/vue-start/plugin/vite' import vueJsx from '@vitejs/plugin-vue-jsx' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/streaming-peak/react/vite.config.ts b/benchmarks/memory/server/scenarios/streaming-peak/react/vite.config.ts index 5af0f0d138..11639a2665 100644 --- a/benchmarks/memory/server/scenarios/streaming-peak/react/vite.config.ts +++ b/benchmarks/memory/server/scenarios/streaming-peak/react/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/react-start/plugin/vite' import react from '@vitejs/plugin-react' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/streaming-peak/shared.ts b/benchmarks/memory/server/scenarios/streaming-peak/shared.ts index 6b45470329..148649a854 100644 --- a/benchmarks/memory/server/scenarios/streaming-peak/shared.ts +++ b/benchmarks/memory/server/scenarios/streaming-peak/shared.ts @@ -9,7 +9,7 @@ export type { StartRequestHandler } type Framework = 'react' | 'solid' | 'vue' const benchmarkSeed = 0xdecafbad -const streamingPeakIterations = 20 +const streamingPeakIterations = 1 const fallbackMarker = 'streaming-peak-fallback-0' const requestInit = { @@ -50,7 +50,7 @@ async function readStreamingBody(response: Response) { let body = '' let chunkCount = 0 - while (true) { + for (;;) { const result = await reader.read() if (result.done) { @@ -98,8 +98,6 @@ export function createWorkloadGroup( iterations: streamingPeakIterations, buildRequest: buildStreamingRequest, validateResponse: validateStreamingResponse, - pinGcBetweenIterations: true, - verifyGcFloor: true, }) return { diff --git a/benchmarks/memory/server/scenarios/streaming-peak/solid/vite.config.ts b/benchmarks/memory/server/scenarios/streaming-peak/solid/vite.config.ts index 18bf5b2d04..8a47faf33a 100644 --- a/benchmarks/memory/server/scenarios/streaming-peak/solid/vite.config.ts +++ b/benchmarks/memory/server/scenarios/streaming-peak/solid/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/solid-start/plugin/vite' import solid from 'vite-plugin-solid' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/scenarios/streaming-peak/vue/vite.config.ts b/benchmarks/memory/server/scenarios/streaming-peak/vue/vite.config.ts index 7cd481da0b..3dbe508d1c 100644 --- a/benchmarks/memory/server/scenarios/streaming-peak/vue/vite.config.ts +++ b/benchmarks/memory/server/scenarios/streaming-peak/vue/vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config' import codspeedPlugin from '@codspeed/vitest-plugin' import { tanstackStart } from '@tanstack/vue-start/plugin/vite' import vueJsx from '@vitejs/plugin-vue-jsx' +import { memoryExecArgv } from '../../../../runtime' const rootDir = fileURLToPath(new URL('.', import.meta.url)) @@ -27,11 +28,8 @@ export default defineConfig({ // and the mid-measurement recompile injects a multi-MB allocation // burst at a run-dependent time. execArgv: [ + ...memoryExecArgv(), '--no-flush-bytecode', - // Pre-size the V8 heap so no space has to grow mid-measurement: - // heap-growth events allocate several MB at a run-dependent moment, - // which flips the measured peak bimodally between identical runs. - '--initial-old-space-size=64', '--min-semi-space-size=16', '--max-semi-space-size=16', ], diff --git a/benchmarks/memory/server/tsconfig.json b/benchmarks/memory/server/tsconfig.json index 5d5dcbf825..499ec37192 100644 --- a/benchmarks/memory/server/tsconfig.json +++ b/benchmarks/memory/server/tsconfig.json @@ -3,5 +3,11 @@ "compilerOptions": { "types": ["node", "vite/client", "vitest/globals"] }, - "include": ["bench-utils.ts"] + "include": [ + "bench-utils.ts", + "scenarios/*/shared.ts", + "../runtime.ts", + "*.test.ts", + "vitest.unit.config.ts" + ] } diff --git a/benchmarks/memory/server/vitest.unit.config.ts b/benchmarks/memory/server/vitest.unit.config.ts new file mode 100644 index 0000000000..19405a6f92 --- /dev/null +++ b/benchmarks/memory/server/vitest.unit.config.ts @@ -0,0 +1,9 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + watch: false, + environment: 'node', + include: ['*.test.ts'], + }, +}) diff --git a/benchmarks/memory/tsconfig.json b/benchmarks/memory/tsconfig.json new file mode 100644 index 0000000000..5a325f3b6c --- /dev/null +++ b/benchmarks/memory/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "types": ["node"] + }, + "include": ["runtime.ts"] +}