Profiling a partially evaluated program

后端 未结 1 848
臣服心动
臣服心动 2021-02-19 12:00

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

1条回答
  •  日久生厌
    2021-02-19 12:37

    Most likely, the second signal is being delivered before the program has finished handling the first one, and at this point the signal's action has been reset to the default action, which (for SIGINT) is to terminate the program. Because of the swapping, there's a significant interval before the profiling code can write out the profiling data, during which time the program is vulnerable to a second SIGINT.

    Moral of the story: be patient. If you wait long enough, the program will finish and the data will be written out. Regarding that second ^C, tell yourself, "Just don't do it!" :-)

    One could argue that the Haskell runtime should set signal options such that a second SIGINT is ignored, but that would be risky because there'd be no easy way to terminate the program if things got really messed up trying to handle the signal.

    You probably also want to avoid programs that exceed physical memory and induce a lot of swapping. At that point, your computation is effectively stalled and there's not much point in continuing. Use +RTS -M to limit the heap size to avoid getting into this situation.

    0 讨论(0)
提交回复
热议问题