Skip to content

Worker-wrapper optimization working in GHC 8.8 no longer works in 8.10

Summary

For a particular case in the streamly library, worker wrapper that was working well in GHC 8.8 does not seem to be working in 8.10.

Steps to reproduce

  1. Clone the streamly repo from https://github.com/composewell/streamly . checkout the ghc-8.10-worker-wrapper branch.
  2. Have ghc-8.8 in your PATH and use cabal build streamly to build
  3. from the repo root run ghc -O2 -fmax-worker-args=16 -ddump-simpl -ddump-to-file -dsuppress-all src/Streamly/Internal/Data/Stream/SVar.hs
  4. Save src/Streamly/Internal/Data/Stream/SVar.dump-simpl

Repeat these steps for ghc-8.10 and compare the resulting Core files. Look at the core of the function fromStreamVar. In GHC 8.8 the worker function $wfromStreamVar has calls to itself, whereas in GHC 8.10 it calls the wrapped function fromStreamVar.

I did a phase wise comparison of GHC 8.8 and 8.10 output and found that the code has almost no difference before the worker-wrapper bind phase, the above mentioned difference starts from that phase onwards. I am attaching the cores before and after worker-wrapper bind phase for both GHC 8.8 and 8.10 in this issue for quick look.

Expected behavior

Worker wrapper should work in 8.10 in the same way as it works in 8.8 . If not what is the reason behind it why it cannot work?

Environment

GHC 8.8 and GHC 8.10 comparison.

Optional:

Mac OS X x86_64

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information