4 ms·
How do you tell which optimization level is better for your program other than just running both? Shouldn't one expect that the higher optimization level would
by gravypod 9y ago
How do you tell which optimization level is better for your program other than just running both? Shouldn't one expect that the higher optimization level would push more performance?
Does GHC have a -Ofast?
- chrisseaton 9y ago> Shouldn't one expect that the higher optimization level would push more performance? 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.
- pletnes 9y agoThe same can be said for gcc - basically, optimization heuristics are sometimes incorrect.
- carterschonwald 9y agoFor arbitrary programs, the only way to determine performance is to measure measure measure. Anything else requires having a perfect model of the running system and the hardware and environment. Which is best replicated by measuring the actual performance. 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 :)