Closed Gabriella439 closed 1 year ago
(I have also reproduced this on a regular Intel Mac, in case anyone is worried about the M1 running x86 causing weirdness)
Interesting, thanks for the report! I can reproduce this on x86_64-linux using GHC 9.4.3 (and also on 9.4.2). The fixity-th
flag seems to be a magnet for GHC bugs, cf. #927...
PR to disable fixity-th
on GHC 9.4 for the time being: #945
Describe the bug
ormolu
is significantly slower when formatting expressions that mix operators of different fixities iformolu
was built withfixity-th
enabled (which is the default).To Reproduce
To reproduce this behavior, build
ormolu
with thefixity-th
flag enabled (which is the default) and then format the following file:This will take a while (≈ 43 seconds on my machine).
The problem disappears if you build
ormolu
without thefixity-th
flag or if you build using GHC 9.2 or older. In those cases formatting speed goes back to normal (≈ 0.2 seconds).Expected behavior
The performance with
fixity-th
shouldn't be significantly slower than withoutfixity-th
. My understanding is that thefixity-th
flag is supposed to be an optimization (to compile the fixity look-up table at compile-time usingTemplateHaskell
instead of decoding the look-up table at runtime) but in this case it's actually significantly less efficient due to some change introduced in GHC 9.4.Environment
macOS 13.0.1
x86_64-darwin
Note: I'm actually on an M1 mac, but I compile for
x86_64-darwin
due issues buildingormolu
withfixity-th
enabled onaarch64-darwin
. For more details, see: https://github.com/NixOS/nixpkgs/issues/194367ormolu-0.5.1.0
ghc-9.4.2