Open DanielNoord opened 1 month ago
This is the first time I see an issue like this, especially an error around the thread pool. I wonder now if your CI allows you to spawn threads.
Other output in the same run is:
Formatted 0 files in 792µs. No fixes needed. 00:05
Formatted 0 files in 3ms. No fixes needed. 00:05
Formatted 1 file in 8ms. No fixes needed. 00:05
Formatted 0 files in 2ms. No fixes needed. 00:05
Formatted 0 files in 770µs. No fixes needed. 00:05
Formatted 1 file in 2ms. No fixes needed. 00:05
Formatted 1 file in 3ms. No fixes needed.
Also, this doesn't happen all the time. I would guess about 10% of the time. I can ask the team maintaining the CI whether we allow spawning threads, but wouldn't this then be an issue for all CI runs?
Maybe this issue can shed some light on the matter. However, I think this is an issue around the CI environment: https://github.com/rust-lang/rust/issues/69140
Heya, colleague of @DanielNoord (and complete Rust noob) here.
For context, our CI runs on a beefy machine with 192 logical CPUs.
If I understand the biome code and the thread pool docs correctly, the thread pool in biome is constructed without specifying num_threads
, meaning:
the ... number of threads ... is based on the RAYON_NUM_THREADS environment variable (if set), or the number of logical CPUs (otherwise).
We don't have RAYON_NUM_THREADS
set, so I suspect it's using 192 threads.
Often we're running multiple CI runs at the same time, so if it randomly happens that we have a bunch of biome instances running concurrently, maybe we're just hitting some limit to the number of threads, or some other resource limit.
If this is what's happening, then we could work around it by setting RAYON_NUM_THREADS
much lower. Maybe it makes sense for biome to default to a more conservative maximum number of threads, and/or point this out in the output or docs (so that the next person with this problem doesn't have to dive into the code)?
With RAYON_NUM_THREADS=4
it seems to work fine.
I'm not so sure anymore about my theory of multiple biome instances running at the same time, since biome only takes like 1 second and we don't have that many concurrent CI runs. Anyway, I think we'll just set RAYON_NUM_THREADS
and call it a day.
I would still suggest adding a hint to the error or docs, or defaulting to a lower max number of threads.
Maybe on ThreadPoolBuildError
, biome could not say "this is bug in biome, not in your code" but something more like "looks like you don't have enough resources for the thread pool, try setting RAYON_NUM_THREADS to something low"?
My 2c :)
Thanks for your help @ematipico!
That's definitely a good suggestion. I think I will create a new environment variable for CI environments that will alias the Rayon one
Environment information
Note that this is the environment from my personal machine. The error itself occurs sporadically on our CI runners on which I can't run
biome rage
easily.What happened?
Run
biome format --files-ignore-unknown=true --no-errors-on-unmatched
, got:We run that command via
pre-commit
with the following hook definition:Expected result
No error.
Code of Conduct