Skip to content

Commit 3998fbb

Browse files
committed
More sane evals default concurrency + staggered startup
1 parent 5c3237a commit 3998fbb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

evals/apps/cli/src/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { getExercises } from "./exercises.js"
3636
type TaskResult = { success: boolean; retry: boolean }
3737
type TaskPromise = Promise<TaskResult>
3838

39-
const MAX_CONCURRENCY = 20
39+
const MAX_CONCURRENCY = 5
4040
const TASK_TIMEOUT = 10 * 60 * 1_000
4141
const UNIT_TEST_TIMEOUT = 60 * 1_000
4242

@@ -115,8 +115,9 @@ const run = async (toolbox: GluegunToolbox) => {
115115

116116
// Retries aren't implemented yet, but the return values are set up to
117117
// support them.
118-
const processTask = async (task: Task) => {
118+
const processTask = async (task: Task, delay = 0) => {
119119
if (task.finishedAt === null) {
120+
await new Promise((resolve) => setTimeout(resolve, delay))
120121
const { retry } = await runExercise({ run, task, server })
121122

122123
if (retry) {
@@ -141,12 +142,15 @@ const run = async (toolbox: GluegunToolbox) => {
141142
}
142143
}
143144

145+
let delay = 0
144146
for (const task of tasks) {
145-
const promise = processTask(task)
147+
const promise = processTask(task, delay)
148+
delay = delay + 5_000
146149
runningPromises.push(promise)
147150
promise.then(() => processTaskResult(task, promise))
148151

149-
if (runningPromises.length > MAX_CONCURRENCY) {
152+
if (runningPromises.length >= MAX_CONCURRENCY) {
153+
delay = 0
150154
await Promise.race(runningPromises)
151155
}
152156
}

0 commit comments

Comments
 (0)