DRAFT Add ghc flag -jsem
This patch adds a flag to ghc allowing the parallelism of
--make to be controlled with a POSIX semaphore, allowing parallel invocations of
ghc --make to cooperate in limiting their CPU bound threads.
Several details remain to be decided, so this remains a draft:
- what should the flag be called? -jsem seems quite terrible
- An implementation for windows should be provided
- Should we instead(or as well) conform to the GNU make jobserver protocol? https://www.gnu.org/software/make/manual/html_node/Job-Slots.html
- Clients of GNU make jobserver are expected to have 1 active job, then claim additional jobs from the jobserver. This implementation just replaces the old QSem with a posix semaphore, so a ghc may have 0 active jobs. Is this Okay?
Building lens and it's dependencies from scratch on a 12 core machine shows some improvement:
Command being timed: "cabal --store-dir /home/doug/code/ghc.jsem/lenstest/_out/store v2-build lens --offline --ghc-options=-j -j" User time (seconds): 522.76 System time (seconds): 44.70 Percent of CPU this job got: 386% Elapsed (wall clock) time (h:mm:ss or m:ss): 2:26.76
Command being timed: "cabal --store-dir /home/doug/code/ghc.jsem/lenstest/_out/store v2-build lens --offline --ghc-options=-j -jsem ghc.sem -j" User time (seconds): 416.23 System time (seconds): 28.51 Percent of CPU this job got: 335% Elapsed (wall clock) time (h:mm:ss or m:ss): 2:12.51