perf: batch visible terminal output floods
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable max-lines -- Scheduler E2E coverage shares one booted Electron app and debug API. */
|
||||
/**
|
||||
* E2E repro for terminal output bursts from many background tabs.
|
||||
*
|
||||
@@ -19,8 +20,10 @@ import { getTerminalContent, waitForActiveTerminalManager } from './helpers/term
|
||||
|
||||
type SchedulerDebugSnapshot = {
|
||||
backgroundEnqueueCount: number
|
||||
deferredForegroundEnqueueCount: number
|
||||
foregroundWriteCount: number
|
||||
backgroundWriteCount: number
|
||||
deferredForegroundWriteCount: number
|
||||
flushWriteCount: number
|
||||
scheduledDrainCount: number
|
||||
drainWrites: number[]
|
||||
@@ -276,6 +279,49 @@ test.describe('Terminal output scheduler', () => {
|
||||
.toBe(true)
|
||||
})
|
||||
|
||||
test('visible bulk output uses the high-priority drain instead of synchronous xterm writes', async ({
|
||||
orcaPage
|
||||
}, testInfo) => {
|
||||
await waitForSessionReady(orcaPage)
|
||||
await waitForActiveWorktree(orcaPage)
|
||||
await ensureTerminalVisible(orcaPage)
|
||||
await waitForActiveTerminalManager(orcaPage, 30_000)
|
||||
|
||||
const activeTabId = await createTerminalTab(orcaPage)
|
||||
if (!activeTabId) {
|
||||
throw new Error('Expected a fresh terminal tab')
|
||||
}
|
||||
const ptyId = await waitForTabPtyId(orcaPage, activeTabId)
|
||||
await resetSchedulerDebug(orcaPage)
|
||||
|
||||
const runId = Date.now()
|
||||
const marker = `VISIBLE_THROUGHPUT_${runId}`
|
||||
const floodCommand = nodeScriptCommand(
|
||||
`const marker='VISIBLE' + '_THROUGHPUT_' + '${runId}'; process.stdout.write('VISIBLE_FILL_${runId}\\n' + 'x'.repeat(700000) + '\\n' + marker + '\\n')`
|
||||
)
|
||||
|
||||
await sendPtyCommands(orcaPage, [{ ptyId, command: floodCommand }])
|
||||
|
||||
await expect
|
||||
.poll(async () => (await getTerminalContent(orcaPage, 12_000)).includes(marker), {
|
||||
timeout: 30_000,
|
||||
message: 'Active terminal did not render the visible throughput marker'
|
||||
})
|
||||
.toBe(true)
|
||||
|
||||
const debug = await getSchedulerDebug(orcaPage)
|
||||
await testInfo.attach('terminal-visible-throughput-proof', {
|
||||
body: JSON.stringify(debug, null, 2),
|
||||
contentType: 'application/json'
|
||||
})
|
||||
testInfo.annotations.push({
|
||||
type: 'terminal-visible-throughput',
|
||||
description: `foreground=${debug.foregroundWriteCount} deferredForegroundEnqueue=${debug.deferredForegroundEnqueueCount} deferredForegroundWrite=${debug.deferredForegroundWriteCount} drains=${debug.drainWrites.join(',')}`
|
||||
})
|
||||
expect(debug.deferredForegroundEnqueueCount).toBeGreaterThan(0)
|
||||
expect(debug.deferredForegroundWriteCount).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
test('hidden overflow restores from main-owned terminal state when the tab becomes visible', async ({
|
||||
orcaPage
|
||||
}) => {
|
||||
|
||||
Reference in New Issue
Block a user