Files
orca/config/scripts/dev-rolldown-runtime-env.test.mjs
T
OrcaWinandOrcaWin 7324dada30 perf(dev): −1.2 GB idle RSS per pnpm dev instance (Rolldown threads + mimalloc purge) (#33836)
* perf(dev): size the dev server's Rolldown runtime for many parallel instances

~93% of idle electron-vite RSS is Rolldown's native mimalloc arenas. The dev
wrapper now gives electron-vite MIMALLOC_PURGE_DELAY=0 and 4 Rolldown/Rayon
threads; a serve-only renderer plugin strips exactly those keys before
Electron spawns, so dev Orca's terminals never inherit them.

* fix(dev): add the runtime-env plugin only when the dev wrapper set its keys

Keeps createDevServeConfig returning the renderer config unchanged when there
is no port and nothing to strip, as electron-vite-output-contract pins.

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-10-26 01:39:36 -07:00

26 lines
826 B
JavaScript

import { describe, expect, it } from 'vitest'
import {
removeDevRolldownRuntimeEnv,
withDevRolldownRuntimeEnv
} from './dev-rolldown-runtime-env.mjs'
describe('dev Rolldown runtime env', () => {
it('removes only the keys it added, keeping caller choices', () => {
const env = withDevRolldownRuntimeEnv({ RAYON_NUM_THREADS: '2', PATH: '/bin' }, 24)
expect(env).toMatchObject({
MIMALLOC_PURGE_DELAY: '0',
ROLLDOWN_WORKER_THREADS: '4',
RAYON_NUM_THREADS: '2'
})
removeDevRolldownRuntimeEnv(env)
expect(env).toEqual({ RAYON_NUM_THREADS: '2', PATH: '/bin' })
})
it('keeps Rolldown thread defaults on small hosts', () => {
expect(withDevRolldownRuntimeEnv({}, 4)).toEqual({
MIMALLOC_PURGE_DELAY: '0',
ORCA_DEV_RUNTIME_ENV_KEYS: 'MIMALLOC_PURGE_DELAY'
})
})
})