Skip to content

Commit aced947

Browse files
committed
fix: keep the first measured ELU interval in the webapp bench
The baseline reading was fired without awaiting it, so a sampling tick that landed before that round trip resolved saw no previous reading and recorded a zero delta. stopEluSampling() compensated by dropping the first sample unconditionally, which also discarded a genuine measured interval and could leave a short run with no samples at all. The baseline is now awaited before the interval starts, so every recorded sample is a real delta and the drop is gone.
1 parent 733d0f7 commit aced947

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

apps/webapp/test/bench/engineHttp.bench.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ describe("engine worker-action HTTP CPU benchmark", () => {
147147
let emptyDequeues = 0;
148148

149149
await profiler.startCpuProfile(SAMPLING_INTERVAL_US);
150-
profiler.startEluSampling();
150+
await profiler.startEluSampling();
151151
recorder.begin();
152152

153153
await runLoad({

apps/webapp/test/bench/lib/cdp.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,17 @@ export class WebappProfiler {
169169
}
170170

171171
/**
172-
* The first evaluate seeds a baseline reading so that the first recorded
173-
* delta is measured from the moment sampling started rather than from
174-
* process boot.
172+
* Awaits a baseline reading before the interval starts, so the first recorded
173+
* delta is measured from the moment sampling started rather than from process
174+
* boot. Awaiting matters: the baseline is a round trip to the target, and a
175+
* tick that landed before it resolved would report a zero delta and drag the
176+
* average down.
175177
*/
176-
startEluSampling(intervalMs = 250): void {
178+
async startEluSampling(intervalMs = 250): Promise<void> {
177179
this.eluSamples = [];
178180
this.eluStartedAt = Date.now();
179181

180-
void this.evaluateElu();
182+
await this.evaluateElu();
181183

182184
const timer = setInterval(() => {
183185
void this.evaluateElu().then((utilization) => {
@@ -216,17 +218,13 @@ export class WebappProfiler {
216218
}
217219
}
218220

219-
/**
220-
* Drops the seeded first sample, which spans the gap between attach and the
221-
* start of load and therefore reads artificially low.
222-
*/
223221
stopEluSampling(): { stats: EluStats; samples: EluSample[] } {
224222
if (this.eluTimer) {
225223
clearInterval(this.eluTimer);
226224
this.eluTimer = null;
227225
}
228226

229-
const samples = this.eluSamples.slice(1);
227+
const samples = this.eluSamples;
230228
if (samples.length === 0) {
231229
return { stats: { mean: 0, p50: 0, p95: 0, p99: 0, max: 0, sampleCount: 0 }, samples };
232230
}

0 commit comments

Comments
 (0)