This is the fifth edition of our GHC activities report, which is intended to provide regular updates on the work on GHC and related projects that we are doing at Well-Typed. This edition covers roughly the months of February and and March 2021.
The previous editions are here:
- December 2020 and January 2021
- October and November 2020
- August and September 2020
- June and July 2020
A bit of background: One aspect of our work at Well-Typed is to support GHC and the Haskell core infrastructure. Several companies, including IOHK and Facebook, are providing us with funding to do this work. We are also working with Hasura on better debugging tools. We are very grateful on behalf of the whole Haskell community for the support these companies provide.
If you are interested in also contributing funding to ensure we can continue or even scale up this kind of work, please get in touch.
Of course, GHC is a large community effort, and Well-Typed’s contributions are just a small part of this. This report does not aim to give an exhaustive picture of all GHC work that is ongoing, and there are many fantastic features currently being worked on that are omitted here simply because none of us are currently involved in them in any way. Furthermore, the aspects we do mention are still the work of many people. In many cases, we have just been helping with the last few steps of integration. We are immensely grateful to everyone contributing to GHC. Please keep doing so (or start)!
- Ben Gamari finalized releases of GHC 8.10.4 and 9.0.1, and started work on 9.0.2. Additionally, he worked to finish and merge the outstanding patches pending for GHC 9.2, culminating in an alpha release candidate (9.2.1-alpha1).
- Ben also prepared a blog post updating the community on the state of GHC on Apple M1 hardware.
- Doug Wilson proposed adding interprocess semaphore support to allow multiple concurrent compiler processes to make better use of available parallelism (!5176).
- Matthew Pickering performed some simulations and experiments of the proposed changes to increase the parallelism in
--makemode (#14095) and the effect of the Doug’s
-jsemflag (!5176). The results show both changes have potential to improve compile times when many cores are available.
- Matt opened a GHC proposal to modify the import syntax to distinguish between modules which are used at compile time and runtime. This will mean that enabling
TemplateHaskellin your project will cause less recompilation when using ghci and haskell-language-server.
- Ben fixed a long-standing bug rendering the GHCi linker unable to locate dynamic libraries when not explicitly added to
Profiling and Debugging
- Matt landed the last of the
ghc-debugpatches into GHC, so it will be ready for use when GHC 9.2 is released.
- Matt has finished off a patch which Ben and David Eichmann started which fixes races in the eventlog implementation. This makes it possible to reliably restart the eventlog and opens up the possibility of remote monitoring tooling which connects to the eventlog over a socket. Matt has made a start on implementing libraries which allow monitoring in this way.
- Matt enhanced the restart support for the eventlog by ensuring certain initialisation events are re-posted every time the eventlog is restarted (!5186).
- Matt added new events to the eventlog which track the current number of allocated blocks and some statistics about memory fragmentation (!5126).
- To aid in recent compiler-performance investigations, Ben has been working on merging corediff, a utility for performing structural comparisons on Core, into his ghc-dump tool.
- Matt investigated some discrepancies between OS reported memory usage and live bytes used by a program. This resulted in a new RTS flag (
-Fd) in !5036 and a fix which reduces fragmentation due to nursery blocks (!5175). This work is described in more detail in a recent blog post.
- Adam Gundry has been investigating the extremely poor performance of type families that do significant computation (#8095), building on previous work by Ben and Simon Peyton Jones on “coercion zapping”. He has an experimental patch that can significantly improve performance in some cases (!5286), although more work is needed.
- Andreas Klebinger refactored the way the simplifier creates uniques (!4804). This reduces compiler allocations by between 0.1% to 0.5% when compiling with
- Andreas also stomped out some sources of thunks in the simplifier (!4808). The impact varies by program but allocations for GHC were reduced by ~1% in common cases and by up to 4% for particular tests.
- Andreas also finished a similar patch for the code generator (!5236). This mostly benefits users frequently compiling with
-O0where we save around 0.2% of allocations.
- Andreas and Ben also applied the one-shot trick (#18202) to a few more monads inside of GHC. In aggregate this should reduce GHC’s allocations by another half percent in the common case.
- Matt started working on compile time performance and fixed some long standing leaks in the demand analyser. He used
-hiprofiling in order to quickly find where the leaks were coming from.
- Matt and Ben started work on a public Grafana dashboard to display the long-term trends in compiler benchmarks in an easy to understand way, taking advantage of the performance measurement infrastructure developed over the last 12 months.
- Ben is investigating a significant regression in compiler performance of the
aesonlibrary (#19478) in GHC 9.0.
- Ben reworked the derivation logic for
Enuminstances, significantly reducing the quantity of code required for such instances.
- Andreas has fixed a few more obstacles which will allow GHC to turn on
-fstrict-dictsby default (!2575) when compiling with -O2.
- Andreas investigated a runtime regression with GHC 9.0.1 (#19474) which ultimately was caused by
vectorregressing under certain circumstances. This was promptly fixed by Ben upstream.
- After a review by Simon Peyton Jones, Andreas is evaluating a possible simplification in the implementation of his tag inference analysis.
- Ben investigated and fixed a runtime regression in
bytestringcaused by GHC 9.0’s less-aggressive simplification of
Andreas investigated and fixed (!4926) an issue where the behaviour of
unsafeDupablePerformIOhad changed in GHC 9.0 as a result of more aggressive optimisation of
runRW#. In particular when a user wrote code like:
Before the fix it was possible for
xto be evaluated before the write to the
Ben fixed a bug resulting in the linker failing to load libraries with long paths on Windows (#19541)
Ben fixed a rather serious garbage-collector bug affecting code unloading in GHC 8.10.4 and 9.0.1 (#19417).
Compiler functionality and language extensions
- Adam assisted with landing the
NoFieldSelectorsextension (!4743) and the record dot syntax extensions (!4532). Both of these features will be in GHC 9.2, although record dot syntax will be properly supported only for selection, not for record update. Adam is working on a GHC proposal to address outstanding design questions regarding record update.
- Ben finished and merged the
BoxedRepimplementation started by Andrew Martin, allowing true levity polymorphism in GHC 9.2 (#17526)
- Ben has been working with a contributor to finish stack snapshotting functionality, which will allow backtraces on all platforms supported by GHC.
Compiler error messages refactoring
- Alfredo Di Napoli continued to work on GHC’s Structured Error Messages (#18516), working with Richard Eisenberg on redesigning the way GHC classifies and emits diagnostic information. The design work resulted in an updated Wiki design and !5116.