Skip to content

readPipedStdin time measurement incorrectly includes createAgentSessionRuntime #4829

@7sDream

Description

@7sDream

What happened?

With PI_TIMING=1, the readPipedStdin timing marker reports ~9s, but the actual stdin read takes <1ms. The marker is placed after await createAgentSessionRuntime(...), so the runtime creation time leaks into the readPipedStdin measurement.

time("createRuntime");
const runtime = await createAgentSessionRuntime(createRuntime, { ... });  // ← heavy work goes here
// ...
stdinContent = await readPipedStdin();
time("readPipedStdin");   // ← includes everything since the previous time() call

Steps to reproduce

PI_TIMING=1 PI_STARTUP_BENCHMARK=1 pi

Observe that readPipedStdin dominates the timing output, while there is no separate entry for createAgentSessionRuntime.

Expected behavior

createAgentSessionRuntime should have its own timing entry so the real bottleneck is visible. Adding a time("createAgentSessionRuntime") right after the call resolves this.

time("createRuntime");
const runtime = await createAgentSessionRuntime(createRuntime, { ... });
time("createAgentSessionRuntime");   // ← add this
// ...
stdinContent = await readPipedStdin();
time("readPipedStdin");

Version

0.75.4

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinginprogressIssue is being worked on

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions