New browser instance per benchmark task#808
Merged
Merged
Conversation
pgarrison
commented
May 28, 2026
Comment on lines
5
to
-24
| @@ -14,14 +12,6 @@ function setStatus(msg: string) { | |||
| console.log("[benchmark]", msg); | |||
| } | |||
|
|
|||
| // Nearest-rank percentile over a pre-sorted array. Used to report p50 and p95 | |||
| // across timed iterations — p95 surfaces occasional slow outliers (GC pauses, | |||
| // DuckDB cache misses) that the median would hide. | |||
| function percentile(sorted: number[], p: number): number { | |||
| const idx = Math.ceil((p / 100) * sorted.length) - 1; | |||
| return sorted[Math.max(0, idx)]; | |||
| } | |||
|
|
|||
Contributor
Author
There was a problem hiding this comment.
These were moved to stats.ts for reuse.
pgarrison
commented
May 28, 2026
| }; | ||
| } finally { | ||
| await browser.close(); | ||
| await new Promise((res) => server.close(res)); |
Contributor
Author
There was a problem hiding this comment.
This was moved to line 182
pgarrison
commented
May 28, 2026
| // no HTTP range-request overhead, so DuckDB sort performance matches real-user timing. | ||
| const loaded = new Set(); | ||
| for (const source of testCases.flat()) { | ||
| if (source.label in loaded) continue; // Don't add duplicate sources |
Contributor
Author
There was a problem hiding this comment.
This whole section was moved verbatim to injectFixtures, with one exception: I changed this condition to loaded.has(source.label) to fix a bug. (in does not check set membership!)
BrianWhitneyAI
approved these changes
Jun 1, 2026
Contributor
BrianWhitneyAI
left a comment
There was a problem hiding this comment.
Approved under the assumption the lint issues are cleaned up
SeanDuHare
approved these changes
Jun 2, 2026
Contributor
Author
|
Waiting on https://github.com/AllenInstitute/biofile-finder/actions/runs/26973097008 to complete successfully after latest adjustments |
Contributor
Author
Done 4576877 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Enable benchmarking cold-start scenarios by using a new browser instance for every trial. This feature is enabled only when the user sets
warmups=0.Builds on #739, #806,
Changes
index.ts) accepts an optional list of tasks to run, and runs all tasks by default.run-benchmark-page.tsnow splits the logic intorunInBrowser(forwarmups > 0) andrunColdStartBenchmarks, which makes use ofrunInBrowser.ininstead ofhasfor set membership.stats.ts(may need a better name) andinjectFixturesfor DRY and readability.Testing
Without this change, running tests with
warmups=0shows a significant performance decrease for the first trial of each batch. The test below used 4 batches with 15 or 20 iterations each.Before:

After this change, with
warmups=0, there are no obvious outliers.After (2 batches, 5 iterations each):
