[Haskell-cafe] Compiled program running (extremely) slower than interpreted equivalent (no results produced)
CASANOVA Juan
Juan.Casanova at ed.ac.uk
Fri Jul 16 01:10:36 UTC 2021
Hello,
I have a (fairly complicated) Haskell program.
The main aspect I believe is relevant about it is that it produces an infinite output (something like an infinite list evaluated lazily, except I use my own data structures with better properties).
What I want is to see how fast the elements in the "list" are produced and check that they are correct, without reaching any particular point. Producing even just a couple elements of this list takes A LOT of computations.
I normally run everything interpreted, and this works fine. However, it is a tad too slow and I wanted to profile it, for which I need to compile it.
Here is my typical way to run it interpreted:
* stack ghci +RTS -M500m -RTS
* :load CESQResolverEval.hs
* main
This produces 4-5 outputs within a few seconds.
When I try to compile it:
* stack ghc --rts-options "-M500m" CESQResolverEval.hs
* stack exec ./CESQResolverEval
This dies. Moreover, if I run without the RTS options and/or let it run for a while, it completely kills my computer and I have to restart it.
I initially thought it may be a thing with output flushing but:
* I added a stdout flush after each individual element of the "list", and it changes nothing.
* I even tried changing what main does so that it stops after the first result. This works when interpreted (takes less than a second), but still the program produces nothing and kills my CPU when compiled.
Maybe relevant is that loading my program into GHCi takes about 30 seconds.
The only thing I've been able to find online is this: https://www.reddit.com/r/haskell/comments/3hu3sd/how_is_it_possible_that_compiled_code_is_slower/
But that seems to be about complicated flags and their implications. As you can see, my flags are fairly simple.
Anyone has any idea what this could be about, or how to avoid it? My purpose is to profile the program to see where most of the time is being spent, but I cannot do that without compiling it, and if the compiled code is running much slower than the interpreted code, then it seems absurd to even try to profile this (it must not be doing the same that the interpreted code is doing?).
Thanks in advance,
Juan.
The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. Is e buidheann carthannais a th' ann an Oilthigh Dhùn Èideann, clàraichte an Alba, àireamh clàraidh SC005336.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20210716/e104e9e9/attachment.html>
More information about the Haskell-Cafe
mailing list