feat(scripts): server metrics time the turn pipeline and opening a large thread #41282
Mergedjuliusmarmingemerged 3 commits into
perf/server-metrics-clients fromrefs/pull/41282/headmerged by juliusmarminge View on GitHubtanstack-source added labelsfeature
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -1000,0 +1066,21 @@1066+ const [threadId] = yield* openThreads(server, 0, 1);1067+ if (threadId === undefined) return yield* new MetricsError({ message: "no pipeline thread" });1068+ const toRequest: number[] = [];1069+ const turnEnd: number[] = [];1070+ yield* server.loopStart;1071+ const first = yield* nowMs;1072+ for (let turn = 0; turn < turns; turn++) {1073+ const marker = `bench-run-${20_000 + turn}`;1074+ const started = yield* nowMs;1075+ const sent = yield* server.threadSend(threadId, `Short reply. ${marker}`);1076+ const done = yield* nowMs;1077+ if (sent.exitCode !== 0) {1078+ return yield* new MetricsError({1079+ message: `pipeline turn ${turn} failed: ${sent.stderr.trim() || sent.stdout.trim()}`,1080+ });1081+ }1082+ const request = environment.requests.find(1083+ (entry) => entry.agent && entry.marker === marker && entry.at >= started,1084+ );1085+ if (request?.endedAt === undefined) {1086+ return yield* new MetricsError({ message: `the agent request for ${marker} never ended` });
Pushed996169f
Pushed676bd2a
Pushed2b35e23
Pushed3714076
- @@ -1182,3 +1240,9 @@11821240 };11831241 });118412421243+/**1244+ * Short turns back to back on one thread: how long a send takes to reach the API, how long the1245+ * end of the reply takes to become a finished run the CLI sees (turn end and checkpoint), the time1246+ * per turn, and the event-loop delay across all of them.1247+ */1248+const pipelineTurns = Effect.fn("serverMetrics.pipelineTurns")(function* (
Sign in to join this conversation.
Note
Reviews paused#
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
Walkthrough
The server metrics script adds sequential pipeline-turn measurements and bounded snapshot measurements for the largest seeded thread. The report includes the new metrics, applies its noise floor to open-time measurements, and excludes large-thread message count from numeric comparisons.
Changes: Server metrics scenarios
scripts/server-metrics.ts,scripts/server-metrics-report.tsscripts/server-metrics.ts,scripts/server-metrics-report.tsEstimated code review effort: 3 (Moderate) | ~20 minutes
Change: Feature
Sequence Diagram(s)#
Possibly related issues
Possibly related PRs
Suggested reviewers:
macroscopeappMerge Risk:
Minimal · previous review
37140This adds pipeline and large-thread measurements to the maintainer server benchmark and does not touch product code. No concrete merge-blocking risk was found. The only open item is a minor convention to export the new measurement functions.
Pre-merge checks:
4
Full details: Title check
Explanation
The title names the two main changes: timing the turn pipeline and opening a large thread in the server metrics script. It follows the conventional commit format and matches the changeset, which adds a pipeline scenario and a large-thread busy metric to scripts/server-metrics.ts and scripts/server-metrics-report.ts. The title is 79 characters, which is slightly long but acceptable.
Full details: Description check
Explanation
The description covers the problem, change, scope, and verification sections. It explains why the metrics were added, lists the pipeline and large-thread changes, links the stack and the requesting maintainer, and reports the commands run and the numbers observed. It also states what was not checked (macOS, Windows, and replayed large-thread construction). It does not follow the template's Problem and Scope guidance fully: the template says features are not accepted and that a bug fix should link an issue, and the PR is a tooling addition with no linked issue. The author does explain why no issue is needed. The template also asks for the model and harness at the end, and the author includes that line.
Finishing Touches
Generate unit tests (beta)