Tuesday, March 09, 2010
Haskell profiler with -O2
I had a puzzling Haskell experience today. I was profiling a program and was curious about a function 'new'. The profiler said it was called 29 times, though I found that hard to believe. I added a print statement that showed it is called twice. After being confused for awhile, I finally realized it might be an effect due to the optimizer. I turned optimizations off (-O2 to -O0) and it went back to 2 calls. I don't fully understand the so-called Constant Applicative Form (CAF) centers, but I'm still surprised, even with aggressive inlining that it could occur so frequently. Perhaps it can still count as a call if the inlined body is in a (partially evaluated) thunk.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment