The*_*ive 5 profiling haskell ghc
我正在尝试使用分析来诊断程序中的无限循环。因为我必须使用 Ctrl-C 中止程序,所以 .prof 文件仍为空。据我所知,如果程序崩溃,.prof 文件应该仍然可以工作。
为了测试这是否是我的特定程序的配置,我写了这样的:
module Main (
main
) where
testInf = map (+1) [1..]
main = do
print (show testInf)
Run Code Online (Sandbox Code Playgroud)
我正在使用 Leksah,配置生成以下 .cabal 文件:
name: tests
version: 0.0.1
cabal-version: >=1.2
build-type: Simple
license: AllRightsReserved
license-file: ""
description:
data-dir: ""
executable tests
build-depends: base -any
main-is: Main.hs
buildable: True
hs-source-dirs: src
ghc-options: -prof -auto-all
Run Code Online (Sandbox Code Playgroud)
然后我通过运行来执行该程序tests +RTS -p。当我使用 Crl-C 终止程序时,.prof 文件为 0kb。如果我更改程序,使其不会无限运行,它会在完成后生成完整的 .prof 文件。
其他详情
using version 1.16.0 of the Cabal libraryGlasgow Haskell Compiler, Version 7.6.3, stage 2 booted by GHC version 7.4.1当我运行我的程序时,我遇到了同样的问题systemctl。
我发送了一个SIGTERM信号并收到了一个空*.prof文件。
但是发送SIGINT信号给了我我的.prof文件。
对 GHC 的信号处理进行一些挖掘: https://gitlab.haskell.org/ghc/ghc/blob/master/rts/posix/Signals.c#L510-528
这告诉我们如何SIGINT处理:
* SIGINT handler.
*
* We like to shutdown nicely after receiving a SIGINT, write out the
* stats, write profiling info, close open files and flush buffers etc.
Run Code Online (Sandbox Code Playgroud)
并且:
So the first ^C tries to exit the program
// cleanly, and the second one just kills it.
Run Code Online (Sandbox Code Playgroud)
因此,如果您按^C (SIGINT)一次,并且程序尚未退出,则它可能仍在写入您的*.prof文件并进行其他清理。第二个^C (SIGINT)只是终止并留下一个空*.prof文件。
| 归档时间: |
|
| 查看次数: |
421 次 |
| 最近记录: |