1

I am running an application "as a script" with stack runghc. Naturally, it runs slower that way than when compiled and run with stack exec.

I would like to compare the hotspots of the application as run with "runghc" relative to the compiled version.

I was able to compile my application with profiling enabled via stack build --profile, then generate a flame graph as described here.

Is there any set of compilation flags that could be used to generate a profile-able binary that is identical (edit: in terms of performance) to that executed by runghc?

kostmo
  • 6,222
  • 4
  • 40
  • 51
  • 1
    This seems to me to be a contradiction - "set of compilation flags [... to ...] generate a profile-able binary that is identical to that executed by runghc". `runghc` doesn't compile your program; it interprets it. From the [docs](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/runghc.html): "runghc allows you to run Haskell programs without first having to compile them.". Interpreted programs don't benefit from optimization, so even if you could profile it, you would have no way of improving the performance (other than to compile it with optimizations, of course). – user2407038 Jul 03 '17 at 02:32
  • I've clarified the text - if it is possible, I'd like to obtain a profile-able binary that *performs* identically to the interpreted execution of the code. A flame graph of this binary may still help identify algorithmic performance issues in the interpreted code, and would serve pedagogically to compare interpreted performance vs. optimized-compiled performance. – kostmo Jul 03 '17 at 03:01
  • It is not at all possible to get identical performance from code interpreted by GHC and code compiled by GHC, even without optimizations on the compiled version. It is also not at all possible to use the profiling mechanism of the GHC *compiler* to profile a program interpreted by GHC. You can view these things as limitations of GHC, but I would view them as different tools for different jobs. Also, I disagree that there is pedagogical value to comparing performance of compiled vs. interpreted - these parts of GHC have entirely distinct operational semantics (it is literally apples to oranges) – user2407038 Jul 03 '17 at 03:21

0 Answers0