Making GHC an order of magnitude faster with one neat trick
pixel-druid.com
pixel-druid.com
Disclosure: I help out a teeny itsy bit with ghc on occasion.
That's a "Source", not a "Disclosure". There's no conflict of interest in explaining the internals of an open-source project while being involved in an open-source project.
A disclaimer is only necessary when you have a hidden agenda.
Does GHC have a -Ofast?
Certain libraries , such as any doing fusion based optimization, do generally benefit from O2. But at the end of the day measure measure measure.
I’m not familiar with Ofast. I’ll look it up. Looked it up, nope ghc doesn’t have anything like that, and there’s a few parts I hope to help mature in ghc before it’s safe/sane to even consider the analogue of fast math flags and standards breaking optimization. Especially since changing the meaning of programs via optimization flags would be pretty dangerous for a language like Haskell.
There’s def room for other compilation/semantic models to do aggressive optimization in different ways. But not for Haskell today :)
But we don't always understand how optimisations and code generation techniques will perform in practice, without running it. Ideally we'd have a more formal understanding of the performance of real processors, but we don't.
Your optimisation could generate fewer instructions, but change some cache behaviour, for example. Or use instructions that are faster, but use different registers that changes register pressure and slows things down elsewhere.
With the ackermann function, it's not obvious that the compiler can proof a lack of overflow, and optimize out the bigint-ness.
Since I can't see the graphs, I don't know what input ranges the author used, and thus can't tell if the C version even gave the correct answer.
That’s "Integer". "Int" is fixed-size.