If I wanted to build a new desktop computer in 2025, which CPU would I get if I wanted to prioritise GHC compilation speed? My sense is that single-threaded performance is the most important metric to optimise for (although multi-threaded performance is great too), so fewer faster cores might be better than many relatively slower cores. Maybe something like the AMD Ryzen 9 7950X? A different but possibly related question is which CPU is the best for running Haskell executables, where perhaps multi-threaded performance is more important.
I’m running a AMD Ryzen 9 3900X 12-Core Processor
, works great for me!
I found that the concurrency, in Haskell, works really well for speedups. I like testing my stuff in parallel, it scales with multiple threads per core, very well.
For reference: posit: Posit Numbers
The package’s tests calculate 16-bit precision elementary functions exhaustively, concurrently (at least 13 threads). To replicate, pull it down and run stack test
.
As long as we’re really talking about one desktop, any fast and modern CPU is good. Look into your budget and that the platform around it has all you need. Maybe an iGPU, fast USB, PCIe, enough display connections, etc…
Only thing that comes to mind especially wrt. Haskell is, that the vector instruction utility is lower than in some other languages/ecosystems. So that doesn’t need to be prioritized.
Regarding threading, note that cabal defaults to building each dependency using a single core per ghc invocation, but since GHC 9.8 and cabal 3.12 there is a new semaphore synchronization mechanism which allows multiple GHC invocations to share cores more efficiently, see this blog post:
https://www.well-typed.com/blog/2023/08/reducing-haskell-parallel-build-times/
So perhaps multi threaded performance is becoming more important for build times. Of course it does still depend on the specific dependency structure of the packages that you are building. The blog post shows an example graph of a pandoc build with all dependencies which only reaches more than 6 threads about a third of the time (estimated by eye).
I find that compiling with GHC is often RAM or disk bound rather than CPU bound. So it’s worth making sure you are also getting fast RAM and a fast SSD. Often faster CPUs enable faster RAM so this all goes hand in hand
I recently got a new work laptop with a Intel Core Ultra 9 185H (22 cores) and 64 GB of RAM, and it chews through compilation.
On the work codebase (hundreds of thousands of lines of Haskell), I get a compilation speed of about 100k lines / min.
On the Haskell Language Server side, the memory usage isn’t bad (I’m sitting at a few GBs right now), but I agree with others here that the higher the RAM, the better in general. These days, a development machine with less than 32GB of RAM might start to be constraining.