How to Kill Haskell

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to Kill Haskell

crockeea
For the purposes of profiling a partially evaluated program, I'm interested in knowing the best way to terminate a GHC program. This is useful for profiling programs that take a long time to run, possibly as long as forever. It appears that *if* the program can be terminated with a single ^c, then profiling information is written to output. Sometimes, a single ^c doesn't kill the program, at not before I get impatient and hit ^c again. Usually two ^c will kill the program, but then no profiling data is written to output. As a simple example,

Main.hs
fib n = fib (n - 1) + fib (n - 2)
main = print $ fib 100

Compiling with -prof and running with +RTS -p, I can kill this program with a *single* ^c in the first approximately 10 seconds of execution, but after that only two ^c will do the job. Looking at my resources, this change appears to coincide with the program using all of my physical memory and moving to swap space, however that could also be coincidental.

Why does ^c work sometimes, but not other times for the same program? What is the easiest way to ensure that profiling data will get printed when the program does not terminate on its own?

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: How to Kill Haskell

crockeea
There's some information here, but that doesn't explain why ^c works sometimes and not others, nor if that is indeed the proper way to terminate a program.

On Tuesday, November 18, 2014 9:38:43 AM UTC-5, Eric Crockett wrote:
For the purposes of profiling a partially evaluated program, I'm interested in knowing the best way to terminate a GHC program. This is useful for profiling programs that take a long time to run, possibly as long as forever. It appears that *if* the program can be terminated with a single ^c, then profiling information is written to output. Sometimes, a single ^c doesn't kill the program, at not before I get impatient and hit ^c again. Usually two ^c will kill the program, but then no profiling data is written to output. As a simple example,

Main.hs
fib n = fib (n - 1) + fib (n - 2)
main = print $ fib 100

Compiling with -prof and running with +RTS -p, I can kill this program with a *single* ^c in the first approximately 10 seconds of execution, but after that only two ^c will do the job. Looking at my resources, this change appears to coincide with the program using all of my physical memory and moving to swap space, however that could also be coincidental.

Why does ^c work sometimes, but not other times for the same program? What is the easiest way to ensure that profiling data will get printed when the program does not terminate on its own?

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe