builder: refactor job runner and use a shared semaphore across build jobs

Switching to a shared semaphore allows multi-build operations (compiler tests, package tests, etc.) to use the expected degree of parallelism efficiently.

While refactoring the job runner, the time complexity was also reduced from O(n^2) to O(n+m) (where n is the number of jobs, and m is the number of dependencies).
This commit is contained in:
Nia Waldvogel
2021-12-24 13:19:39 -05:00
committed by Nia
parent bb08a25edc
commit e594dbc133
6 changed files with 151 additions and 115 deletions
+1 -1
View File
@@ -1237,7 +1237,7 @@ func main() {
PrintIR: *printIR,
DumpSSA: *dumpSSA,
VerifyIR: *verifyIR,
Parallelism: *parallelism,
Semaphore: make(chan struct{}, *parallelism),
Debug: !*nodebug,
PrintSizes: *printSize,
PrintStacks: *printStacks,