Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 51 additions & 2 deletions src/main/wsl/wsl-orcad-real-distro-idle-release-lane.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ import { execCommand } from '../ssh/remote-exec/remote-exec-command'
import { readConfirmedRunningWslDistros } from '../wsl-background-distro-gate'
import { readWindowsProcessTableFresh } from '../windows/windows-process-table'
import { resolveWslInteropSpawnCwd } from '../wsl-interop-spawn-directory'
import { buildWslExecArgs, buildWslLoginShellCommand } from '../../shared/wsl-login-shell-command'
import {
buildWslExecArgs,
buildWslInteractiveLoginShellCommand,
buildWslLoginShellCommand
} from '../../shared/wsl-login-shell-command'
import { resolveWslExecutablePath } from './wsl-executable-path'
import { createWslDistroHolder, type WslDistroHolder } from './wsl-distro-holder'
import { WSL_DISTRO_HOLDER_POLL_SECONDS } from './wsl-distro-holder-command'
Expand Down Expand Up @@ -446,6 +450,46 @@ async function restartThroughBridgeExec(): Promise<Receipt> {
return { firstOutputMs }
}

/**
* (c) Old bridge as the app runs it: wsl.exe in a ConPTY with the same setup command the bridge's
* WSL terminals use (cd, PATH, the distro's interactive login shell), the probe typed ahead.
*/
async function restartThroughBridgeConpty(): Promise<Receipt> {
await terminatePlain()
const pty = await import('node-pty')
const probe = outputProbe()
const setup = ['cd "$HOME"', buildWslInteractiveLoginShellCommand()].join(' && ')
const started = performance.now()
const terminal = pty.spawn(
resolveWslExecutablePath(),
buildWslExecArgs(PLAIN, ['sh', '-c', setup]),
{
cols: 120,
rows: 30,
cwd: resolveWslInteropSpawnCwd(),
env: { ...process.env }
Comment on lines +461 to +470

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Baseline measures a different launch

This arm skips setup that the bridge uses: useConptyDll: true, shell wrapper creation, and passing ORCA_SHELL_READY_ROOT through WSLENV. On a fresh lane runner, buildWslInteractiveLoginShellCommand() therefore starts a plain login shell instead of loading the bridge's Bash wrapper. The recorded timings compare different terminal and shell startup paths, so they cannot serve as the intended bridge baseline.

Reuse the bridge's launch setup, environment, and ConPTY options before recording these numbers.

}
)
let output = ''
let firstPaintMs: number | null = null
terminal.onData((data) => {
firstPaintMs ??= Math.round(performance.now() - started)
output += data
})
try {
terminal.write(`${probe.command}\r`)
await waitFor(
'the bridge terminal to answer',
async () => (output.includes(probe.token) ? true : null),
120_000,
50
)
return { firstPaintMs, firstOutputMs: Math.round(performance.now() - started) }
} finally {
terminal.kill()
}
}

// A guest command's output is capped at 1 MiB; read big files in base64 chunks below that.
const GUEST_READ_BLOCK_BYTES = 64 * 1024
const GUEST_READ_BLOCKS_PER_CHUNK = 8
Expand Down Expand Up @@ -506,9 +550,11 @@ async function distroRestartBaseline(): Promise<void> {
await restartThroughBridgeExec()
const host: Awaited<ReturnType<typeof restartThroughHost>>[] = []
const bridge: Receipt[] = []
const conpty: Receipt[] = []
for (let i = 0; i < 3; i++) {
host.push(await restartThroughHost(repoPath))
bridge.push(await restartThroughBridgeExec())
conpty.push(await restartThroughBridgeConpty())
}
const median = (runs: Receipt[], key: string): number =>
runs.map((run) => Number(run[key])).toSorted((a, b) => a - b)[1] ?? 0
Expand All @@ -521,7 +567,10 @@ async function distroRestartBaseline(): Promise<void> {
medianHostSendToFirstOutputMs: median(host, 'sendToFirstOutputMs'),
medianOrcadStartup: medianOrcadStartupTiming(host.map((run) => run.orcadStartup)),
medianHostPhases: medianWslOrcadEnsurePhases(host.map((run) => run.phases)),
medianBridgeExecLowerBoundMs: median(bridge, 'firstOutputMs')
medianBridgeExecLowerBoundMs: median(bridge, 'firstOutputMs'),
bridgeConpty: conpty,
medianBridgeConptyFirstPaintMs: median(conpty, 'firstPaintMs'),
medianBridgeConptyFirstOutputMs: median(conpty, 'firstOutputMs')
}
receipt.orcadStartupProfiles = await profileOrcadRestart(repoPath)
await terminatePlain()
Expand Down
Loading