fix(perf): optimize benchmark worker builds

This commit is contained in:
4gray committed 2026-07-26 23:25:09 +02:00
1 parent df7eee7e52
commit a3a8f6e90c
4 files changed
+42 -6

No files matched your search

@@ -197,7 +197,7 @@ test('the Electron performance wrapper owns build dependencies before its profil
assert.ok(target, 'electron-backend must define build-performance');
assert.equal(target.executor, 'nx:run-commands');
assert.deepEqual(target.dependsOn, [
'electron-backend:build-worker',
'electron-backend:build-worker-performance',
'electron-backend:build-embedded-mpv',
{
projects: ['web', 'remote-control-web'],
@@ -210,6 +210,27 @@ test('the Electron performance wrapper owns build dependencies before its profil
);
});
test('the Electron performance wrapper builds optimized source-mapped workers', () => {
const target = electronProject.targets['build-worker-performance'];
const source = readFileSync(
join(workspaceRoot, 'apps/electron-backend/build-worker.js'),
'utf8'
);
assert.ok(target, 'electron-backend must define build-worker-performance');
assert.equal(target.executor, 'nx:run-commands');
assert.equal(
target.options?.['command'],
'node apps/electron-backend/build-worker.js --performance'
);
assert.match(
source,
/const isPerformance = process\.argv\.includes\('--performance'\)/
);
assert.match(source, /minify: isProduction \|\| isPerformance/);
assert.match(source, /sourcemap: isPerformance \|\| !isProduction/);
});
test('the cancellation benchmark uses the production-equivalent performance build', () => {
const target = e2eProject.targets['benchmark-m3u-refresh-cancellation'];
+9 -3
View File
@@ -18,6 +18,12 @@ const nativeModules = [
];
const isProduction = process.env.NODE_ENV === 'production';
const isPerformance = process.argv.includes('--performance');
const buildMode = isPerformance
? 'performance'
: isProduction
? 'production'
: 'development';
async function buildWorker() {
try {
@@ -59,7 +65,7 @@ async function buildWorker() {
for (const worker of workers) {
console.log(
`Building ${worker.label} with esbuild (${isProduction ? 'production' : 'development'})...`
`Building ${worker.label} with esbuild (${buildMode})...`
);
await esbuild.build({
@@ -74,8 +80,8 @@ async function buildWorker() {
...nodeBuiltins,
...nativeModules,
],
sourcemap: !isProduction,
minify: isProduction,
sourcemap: isPerformance || !isProduction,
minify: isProduction || isPerformance,
alias: {
'@iptvnator/shared/interfaces': path.join(
__dirname,
+8 -1
View File
@@ -12,6 +12,13 @@
"command": "node apps/electron-backend/build-worker.js"
}
},
"build-worker-performance": {
"executor": "nx:run-commands",
"outputs": ["{workspaceRoot}/dist/apps/electron-backend/workers"],
"options": {
"command": "node apps/electron-backend/build-worker.js --performance"
}
},
"build-embedded-mpv": {
"executor": "nx:run-commands",
"cache": false,
@@ -98,7 +105,7 @@
},
"build-performance": {
"dependsOn": [
"electron-backend:build-worker",
"electron-backend:build-worker-performance",
"electron-backend:build-embedded-mpv",
{
"projects": ["web", "remote-control-web"],
+3 -1
View File
@@ -121,7 +121,9 @@ before/after claims.
The target reserves and verifies CDP port 9222, freezes renderer long-task,
frame-gap, and heartbeat probes before forced post-GC heap collection, and
enables opt-in worker profiling. Each worker response retains a raw
builds the Electron main process, renderer, and workers with optimized,
source-mapped performance configurations before enabling opt-in worker
profiling. Each worker response retains a raw
request-scoped record containing request/operation identity, received/work/flush
timestamps, thread CPU, event-loop utilization, event-loop delay, and fixed
unavailability or invalid reasons. Missing or malformed profiling metadata