# \[Well-Typed Blog\] Reducing Haskell parallel build times using semaphores

**URL:** <https://discourse.haskell.org/t/well-typed-blog-reducing-haskell-parallel-build-times-using-semaphores/7211>\
**Category:** Links\
**Created:** [August 4, 2023, 3:06pm UTC](https://discourse.haskell.org/t/well-typed-blog-reducing-haskell-parallel-build-times-using-semaphores/7211 "2023-08-04T15:06:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![adamgundry](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@adamgundry](https://discourse.haskell.org/u/adamgundry)\
**Post date:** [August 4, 2023, 3:06pm UTC](https://discourse.haskell.org/t/well-typed-blog-reducing-haskell-parallel-build-times-using-semaphores/7211/1 "2023-08-04T15:06:40Z")

</div>

[https://well-typed.com/blog/2023/08/reducing-haskell-parallel-build-times/](https://well-typed.com/blog/2023/08/reducing-haskell-parallel-build-times/)

---

<div class="post-metadata">

**Author:** ![michaelpj](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/michaelpj/32/417_2.png) [@michaelpj](https://discourse.haskell.org/u/michaelpj)\
**Post date:** [August 5, 2023, 9:46am UTC](https://discourse.haskell.org/t/well-typed-blog-reducing-haskell-parallel-build-times-using-semaphores/7211/2 "2023-08-05T09:46:14Z")

</div>

Great work! I was wondering if the ideas for chunking up the build pipeline discussed in [#14095: Improve build parallelism · Issues · Glasgow Haskell Compiler / GHC · GitLab](https://gitlab.haskell.org/ghc/ghc/-/issues/14095) are also things you’re investigating? The possibility of having typechecking and code generation running in parallel still seems to me like it could make a big difference even for packages with quite sequential build graphs.

---

<div class="post-metadata">

**Author:** ![mpilgrem](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mpilgrem/32/2529_2.png) [@mpilgrem](https://discourse.haskell.org/u/mpilgrem)\
**Post date:** [February 21, 2026, 7:36pm UTC](https://discourse.haskell.org/t/well-typed-blog-reducing-haskell-parallel-build-times-using-semaphores/7211/3 "2026-02-21T19:36:38Z")

</div>

This has been implemented for Stack by Ching Pei Yang. However, I am thinking about sensible defaults. Is there any reason not to use semaphore by default, when it is supported (GHC 9.8.1 or later with Cabal-3.12.0.0 or later)?

---

<div class="post-metadata">

**Author:** ![Bodigrim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/bodigrim/32/1457_2.png) [@Bodigrim](https://discourse.haskell.org/u/Bodigrim)\
**Post date:** [February 21, 2026, 10:24pm UTC](https://discourse.haskell.org/t/well-typed-blog-reducing-haskell-parallel-build-times-using-semaphores/7211/4 "2026-02-21T22:24:56Z")

</div>

> [@mpilgrem](#):
>
> Is there any reason not to use semaphore by default, when it is supported (GHC 9.8.1 or later with Cabal-3.12.0.0 or later)?

One remaining issue for `cabal-install` is [https://github.com/ghc-proposals/ghc-proposals/pull/673](https://github.com/ghc-proposals/ghc-proposals/pull/673). If GHC is built against `libc` (say, it’s a Debian bindist) and Cabal is build against `musl` (say, it’s an Alpine bindist), the underlying implementations of semaphores will be incompatible. In such scenario Cabal fails hard.

That said, I think that it’s wrong to fail hard and instead a graceful degradation to non-semaphore mode should be implemented. If Stack implements such graceful degradation, there should be no reason not to enable semaphores by default.

---

<div class="post-metadata">

**Author:** ![mpilgrem](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mpilgrem/32/2529_2.png) [@mpilgrem](https://discourse.haskell.org/u/mpilgrem)\
**Post date:** [February 21, 2026, 11:16pm UTC](https://discourse.haskell.org/t/well-typed-blog-reducing-haskell-parallel-build-times-using-semaphores/7211/5 "2026-02-21T23:16:47Z")

</div>

Thanks! As a Windows user, can I play that back? If I understand correctly, if the ‘official’ Stack for Linux is a statically-linked binary built in an Alpine Linux Docker container (which it is), the ‘system’ semaphores that it creates will not be the ones that the GHC for non-musl Linux distributions expects? If I understand correctly, that sounds like a major problem.

---

<div class="post-metadata">

**Author:** ![Bodigrim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/bodigrim/32/1457_2.png) [@Bodigrim](https://discourse.haskell.org/u/Bodigrim)\
**Post date:** [February 21, 2026, 11:20pm UTC](https://discourse.haskell.org/t/well-typed-blog-reducing-haskell-parallel-build-times-using-semaphores/7211/6 "2026-02-21T23:20:26Z")

</div>

Correct, it is a major problem on Linux.

---

<div class="post-metadata">

**Author:** ![Kleidukos](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/kleidukos/32/1213_2.png) [@Kleidukos](https://discourse.haskell.org/u/Kleidukos)\
**Post date:** [February 22, 2026, 10:03am UTC](https://discourse.haskell.org/t/well-typed-blog-reducing-haskell-parallel-build-times-using-semaphores/7211/7 "2026-02-22T10:03:19Z")

</div>

I have yet to find a way to make semaphores work on FreeBSD, so I have to disable the options for the platform in my build systems 😕

---

<div class="post-metadata">

**Author:** ![hasufell](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/hasufell/32/1250_2.png) [@hasufell](https://discourse.haskell.org/u/hasufell)\
**Post date:** [February 22, 2026, 10:10pm UTC](https://discourse.haskell.org/t/well-typed-blog-reducing-haskell-parallel-build-times-using-semaphores/7211/8 "2026-02-22T22:10:13Z")

</div>

I don’t think this is a good design, tbh.

I think the right solution is to develop a GHC daemon. There are some companies interested in that, so maybe it will happen some day.

---

<div class="post-metadata">

**Author:** ![Kleidukos](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/kleidukos/32/1213_2.png) [@Kleidukos](https://discourse.haskell.org/u/Kleidukos)\
**Post date:** [February 23, 2026, 8:37am UTC](https://discourse.haskell.org/t/well-typed-blog-reducing-haskell-parallel-build-times-using-semaphores/7211/9 "2026-02-23T08:37:16Z")

</div>

Yep, see [Hécate's Crackpot Ideas: A compilation server for GHC](https://discourse.haskell.org/t/hecates-crackpot-ideas-a-compilation-server-for-ghc/9985)
