Measure hidden PTY restore latency (#4806)

This commit is contained in:
Neil 2026-06-07 09:49:03 -07:00 committed by GitHub
parent 66a561e18b
commit 6d4065cae5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 7 deletions

View File

@ -74,6 +74,7 @@ function printMarkdownTable(rows) {
['Frames', 'frames'],
['Median', 'median'],
['Worst', 'worst'],
['Restore', 'restore'],
['Max Drift', 'maxTimerDrift'],
['Hidden Skips', 'hiddenSkips'],
['Hidden Chars', 'hiddenSkippedChars'],

View File

@ -201,13 +201,20 @@ export async function runHiddenRealPtyPressureScenario<
expect(measurement.maxTimerDriftMs).toBeLessThan(150)
await deps.releaseTerminalAckGate(orcaPage)
await switchToWorktree(orcaPage, secondWorktreeId)
await expect
.poll(() => getTerminalContent(orcaPage, 20_000), {
timeout: 20_000,
message: 'Hidden PTY output was not restored from main buffer on return'
})
.toContain(`OPENCODE_PRESSURE_DONE_${runId}_`)
const restoreLatencyMs = await measureHiddenOutputRestoreLatency(
orcaPage,
secondWorktreeId,
runId
)
testInfo.annotations.push({
type: 'opencode-hidden-real-pty-restore',
description: `panes=${hiddenPanes.length + 1} restore=${restoreLatencyMs.toFixed(
1
)}ms hiddenSkippedChars=${debug?.hiddenRendererSkippedChars ?? 0} mainPeakInFlightChars=${
mainPressure?.peakRendererInFlightChars ?? 0
} heldAckChars=${ackGate?.heldAckChars ?? 0}`
})
expect(restoreLatencyMs).toBeLessThan(1000)
} finally {
await cleanupHiddenPressureScenario({
deps,
@ -221,6 +228,22 @@ export async function runHiddenRealPtyPressureScenario<
}
}
async function measureHiddenOutputRestoreLatency(
orcaPage: Page,
worktreeId: string,
runId: string
): Promise<number> {
const restoreStart = performance.now()
await switchToWorktree(orcaPage, worktreeId)
await expect
.poll(() => getTerminalContent(orcaPage, 20_000), {
timeout: 20_000,
message: 'Hidden PTY output was not restored from main buffer on return'
})
.toContain(`OPENCODE_PRESSURE_DONE_${runId}_`)
return performance.now() - restoreStart
}
async function startHiddenPressureCommands({
hiddenPanes,
orcaPage,