Skip to content

Commit 844f0a6

Browse files
authored
Turbopack: Lower the IO concurrency limit in CI tests (#84508)
@lukesandberg pointed out that we have test flakes from too many file descriptors open. I think we should significantly raise these limits on the ci runners (@ijjk?), but given that we run 8 tests in parallel, it's probably good anyways for Turbopack to be less aggressive with file IO in our CI.
1 parent a6c48f0 commit 844f0a6

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

.github/workflows/build_reusable.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ env:
110110
NEXT_CI_RUNNER: ${{ inputs.runs_on_labels }}
111111
NEXT_TEST_PROXY_ADDRESS: ${{ inputs.overrideProxyAddress || '' }}
112112

113+
# defaults to 256, but we run a lot of tests in parallel, so the limit should be lower
114+
NEXT_TURBOPACK_IO_CONCURRENCY: 64
115+
113116
jobs:
114117
build:
115118
timeout-minutes: ${{ inputs.timeout_minutes }}

turbopack/crates/turbo-tasks-fs/src/lib.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ mod watcher;
3131
use std::{
3232
borrow::Cow,
3333
cmp::{Ordering, min},
34+
env,
3435
fmt::{self, Debug, Display, Formatter},
3536
fs::FileType,
3637
future::Future,
@@ -193,7 +194,20 @@ where
193194
}
194195

195196
fn create_semaphore() -> tokio::sync::Semaphore {
196-
tokio::sync::Semaphore::new(256)
197+
// the semaphore isn't serialized, and we assume the environment variable doesn't change during
198+
// runtime, so it's okay to access it in this untracked way.
199+
static NEXT_TURBOPACK_IO_CONCURRENCY: LazyLock<usize> = LazyLock::new(|| {
200+
env::var("NEXT_TURBOPACK_IO_CONCURRENCY")
201+
.ok()
202+
.filter(|val| !val.is_empty())
203+
.map(|val| {
204+
val.parse()
205+
.expect("NEXT_TURBOPACK_IO_CONCURRENCY must be a valid integer")
206+
})
207+
.filter(|val| *val != 0)
208+
.unwrap_or(256)
209+
});
210+
tokio::sync::Semaphore::new(*NEXT_TURBOPACK_IO_CONCURRENCY)
197211
}
198212

199213
#[turbo_tasks::value_trait]

0 commit comments

Comments
 (0)