From 86674ed21ef85cae12cfce50148b965746748685 Mon Sep 17 00:00:00 2001 From: Chinesezjc Date: Mon, 17 Aug 2026 20:50:01 +0800 Subject: [PATCH] test(code-runtime-python): budget the wide-value walk for an instrumented lane The O(depth) wide-value regression test ran under `maxWallMs: 20_000`, but the cursor pulls 6M elements one at a time through Python-level frames: ~11s on an idle machine, and more under the coverage lane's V8 instrumentation with several workers sharing a runner. CI reported `timeout` instead of the round-trip. Raise the run's ceiling to 60s inside a 90s vitest timeout, so the runtime's own wall clock still fires first on a genuine hang. The assertion is unchanged and still discriminates: restoring the O(width) `stack.extend` enqueue fails the test with a child-side MemoryError in ~2.6s. --- .../code-runtime-python/tests/runtime.spec.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/code-runtime/code-runtime-python/tests/runtime.spec.ts b/packages/code-runtime/code-runtime-python/tests/runtime.spec.ts index bb953ca9f4..6132527a8d 100644 --- a/packages/code-runtime/code-runtime-python/tests/runtime.spec.ts +++ b/packages/code-runtime/code-runtime-python/tests/runtime.spec.ts @@ -3701,12 +3701,19 @@ describe('PythonCodeRuntime — hostile peer', () => { // frames plus the interpreter exceeded 384 MiB and returned MemoryError as an // exception. Linux-only RLIMIT_AS repro; on macOS the value round-trips // either way, but the fixture stays within the address space so it is honest. - const { runtime } = await setup({ maxValueBytes: 20 * 1024 * 1024, addressSpaceMb: 384, maxWallMs: 20_000 }) + // + // `maxWallMs` is 60s, not the 20s the memory assertion alone needs: the O(depth) + // cursor pulls 6M elements one at a time through Python-level frames, which costs + // ~11s on an idle machine and more under the coverage lane's V8 instrumentation + // with several workers sharing a box. This budget bounds the run without letting a + // loaded runner's scheduling latency read as a `timeout` — what this test asserts + // is the O(depth) memory shape, not a speed claim. + const { runtime } = await setup({ maxValueBytes: 20 * 1024 * 1024, addressSpaceMb: 384, maxWallMs: 60_000 }) const result = await runtime.run({ program: 'return [0] * 6_000_000', bindings: [] }) expect(result.error).toBeUndefined() expect(Array.isArray(result.value)).toBe(true) expect((result.value as number[]).length).toBe(6_000_000) - }, 30_000) + }, 90_000) it('bounds a flood of zero-byte log lines through the per-entry separator charge', async () => { // Blank print() lines carry zero content bytes; without the +1 separator