Commit a20c98e
Ayden Meng
BaseTools: Cap thread count to avoid file descriptor exhaustion
When the number of build threads multiplied by per-thread file
descriptor usage exceeds the system's open file descriptor limit,
some threads may fail to acquire necessary resources (e.g., pipes
or semaphores), leading to deadlocks or hangs during parallel builds.
To prevent this situation, calculate the safety upper limit of
concurrency by dividing the system's maximum file descriptor limit by
4 (multi-processing pipelines use three file descriptors, and POSIX
named semaphores use one file descriptor). The actual thread count is
then clamped to this safe value.
This ensures stable parallel builds even under constrained resource
limits.
Signed-off-by: Ayden Meng <[email protected]>1 parent 31d5b37 commit a20c98e
1 file changed
+4
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
838 | 839 | | |
839 | 840 | | |
840 | 841 | | |
| 842 | + | |
841 | 843 | | |
842 | 844 | | |
843 | 845 | | |
844 | 846 | | |
845 | 847 | | |
846 | 848 | | |
847 | | - | |
| 849 | + | |
| 850 | + | |
848 | 851 | | |
849 | 852 | | |
850 | 853 | | |
| |||
0 commit comments