5 ms·
This seems to be a tooling issue. Given the right hooks, it should be much easier to profile and debug this sort of issue than chasing memory leaks in other lan
by outworlder 11y ago
This seems to be a tooling issue. Given the right hooks, it should be much easier to profile and debug this sort of issue than chasing memory leaks in other languages.
This is like trying to debug leaks in C with printf. It is just not done. Where's Haskell's valgrind-like tool?
- gmfawcett 11y agoThere's quite a bit of tooling already: http://book.realworldhaskell.org/read/profiling-and-optimization.html http://book.realworldhaskell.org/read/profiling-and-optimiza... https://wiki.haskell.org/ThreadScope https://wiki.haskell.org/ThreadScope http://www.slideshare.net/tibbe/highperformance-haskell http://www.slideshare.net/tibbe/highperformance-haskell
- outworlder 11y agoThanks for the links! I'll consume them as time allows. The question then becomes, why couldn't the author use them to help pinpoint the source of his issues?
- gmfawcett 11y agoNeil Mitchell is a well-known Haskell expert, so I'm sure he would have used the available tools (if they were useful in the problem at hand). When reasoning about Haskell code, due to non-strict evaluation you get a kind of "spooky action at a distance." If your program flow is something like "let result = C(B(A())", where A, B, and C are functions, an expression deep within function A may not be evaluated until you are in the middle of evaluating C -- or possibly never evaluated at all, if the value of that A expression isn't required to compute the return value of C. To reason about the runtime behaviour inside A, you may have to reason about the expressions that consume the return value of A. This can feel like chaos to someone who works with imperative languages, and who is used to nice things like explicit, linear stack traces: in Haskell, evaluation is driven by need, not by imperative instruction, and so the execution flow can look inside-out at times. That's not to say that better tooling isn't possible -- but it is a challenging problem.
- codygman 11y ago> "spooky action at a distance." I don't know about spooky, it makes more sense if you think in terms of "call by need".
- LukeHoersten 11y agoGreat questions! I think you're right this is a tooling issue. Haskell has valgrind-like heap/memory analysis built right in but not much for thunk-based memory allocation. Neil's article is really about Haskell's thunk analysis specifically and I imagine we will see some valgrind-for-thunk tools come out of this discussion.