Fix a blocking-pool deadlock in nativelink_util::fs::read_dir [1.6-patch-5] - #2647
Open
cormacrelf wants to merge 3 commits into
Open
cormacrelf wants to merge 3 commits into
cormacrelf wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Member
|
Hi @cormacrelf, Can you please fix the pre-commit hook test that's failing right now? |
cormacrelf
force-pushed
the
1.6-patch-5
branch
from
October 6, 2026 04:58
093b07f to
c1db3d9
Compare
This comment has been minimized.
This comment has been minimized.
…wn_blocking I believe this may have caused deadlock on actions with a lot of inputs (700+)
cormacrelf
force-pushed
the
1.6-patch-5
branch
from
October 6, 2026 05:01
c1db3d9 to
8828633
Compare
This branch was successfully deployed
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.
What and why
The previous implementation acquired a blocking-pool permit and then, from inside that blocking-pool thread, called
Handle::current().block_on(tokio::fs::read_dir(path)). Buttokio::fs::read_diris itself implemented as aspawn_blocking, so this nestedblock_onrequired a second blocking-pool thread to be available to make progress — every call toread_dirneeded two pool threads at once instead of one.Under enough concurrent callers (e.g.
upload_directory's unbounded directory-tree fan-out on an action with many inputs), all blocking-pool threads could end up parked waiting on inner tasks that could never get a thread to run on, freezing everyfs::operation in the process. I believe this may have caused deadlocks on actions with a lot of inputs (700+).Fix: acquire the permit, then simply
.awaittokio::fs::read_dirdirectly instead ofblock_on-ing it — no nested blocking-pool thread is required.Type of change
How was this verified?
New regression test
read_dir_needs_only_one_blocking_threadinnativelink-util/tests/fs_test.rs: builds a runtime withmax_blocking_threads(1)and assertsfs::read_dircompletes within a 5s timeout. The pre-fix implementation deadlocks in this configuration since it requires two blocking-pool threads at once.Risk
Low. Only changes how
read_dirwaits ontokio::fs::read_dir. Removes a layer of blocking in async, so the final code is simpler.AI assistance
Opus did most of the work here.
Checklist
bazel test //...passes locallygit amendsee some docsThis change is