有人能帮我理解这个吗?
$ stack exec -- mvm4x4_amf +RTS -sstderr
mvm4x4_amf: Most RTS options are disabled. Link with -rtsopts to enable them.
$ stack exec --profile -- mvm4x4_amf +RTS -sstderr
Executable named mvm4x4_amf not found on path: [{snip}]我在调试部分找到了在这里上面尝试的第二个命令的建议。( 13场搜索比赛中的第10场:"rts")
在用:stack build --profile重新构建我的Stack项目之后,我得到:
$ stack exec --profile -- mvm4x4_amf +RTS -sstderr
mvm4x4_amf: Most RTS options are disabled. Link with -rtsopts to enable them.如果我用这个代替:
$ stack exec --profile mvm4x4_amf +RTS -sstderr他们是我的程序运行,但我没有得到任何分析信息输出。
如果我“进入”到.stack-work/目录并“手动执行”(正如我在与此问题相关的其他文章中所建议的那样):
$ .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/mvm4x4_amf/mvm4x4_amf +RTS -sstderr
mvm4x4_amf: Most RTS options are disabled. Link with -rtsopts to enable them.然后看来,我的可执行文件实际上并不是为分析而构建的。但是,试图显式地重新构建它以进行分析,将不会产生任何操作:
$ stack build --profile :mvm4x4_amf
$哦,这有帮助吗?
$ stack exec mvm4x4_amf --rts-options --info
[("GHC RTS", "YES")
,("GHC version", "8.6.5")
,("RTS way", "rts_v")
,("Build platform", "x86_64-apple-darwin")
,("Build architecture", "x86_64")
,("Build OS", "darwin")
,("Build vendor", "apple")
,("Host platform", "x86_64-apple-darwin")
,("Host architecture", "x86_64")
,("Host OS", "darwin")
,("Host vendor", "apple")
,("Target platform", "x86_64-apple-darwin")
,("Target architecture", "x86_64")
,("Target OS", "darwin")
,("Target vendor", "apple")
,("Word size", "64")
,("Compiler unregisterised", "NO")
,("Tables next to code", "YES")
]嗯,在更改一个阴谋文件选项和重建过程中,我注意到了一些奇怪的事情:
$ stack build --profile :mvm4x4_amf
luminous-0.5.0.0: unregistering (local file changes: luminous.cabal)
luminous> configure (lib + exe)
Configuring luminous-0.5.0.0...
luminous> build (lib + exe)
Preprocessing library for luminous-0.5.0.0..
Building library for luminous-0.5.0.0..
Preprocessing executable 'mvm4x4_amf' for luminous-0.5.0.0..
Building executable 'mvm4x4_amf' for luminous-0.5.0.0..
luminous> copy/register
Installing library in .../.stack-work/install/x86_64-osx/2428dc603454d346facf6484280fa92531e4d7789d3
3c4dd56c39cf70d79bd7e/8.6.5/lib/x86_64-osx-ghc-8.6.5/luminous-0.5.0.0-9ABiH0AyDmV25JxAv1cFEI
{snip}
Installing executable mvm4x4_amf in .../.stack-work/install/x86_64-osx/2428dc603454d346facf6484280fa
92531e4d7789d33c4dd56c39cf70d79bd7e/8.6.5/bin
{snip}
Registering library for luminous-0.5.0.0..
$ stack exec which mvm4x4_amf
.../.stack-work/install/x86_64-osx/9af8b70f7f84a02189b610f95c8d289ab7d743df5c23a5d5d43b30afe0c02b7c/
8.6.5/bin/mvm4x4_amf 堆栈似乎是在与安装它的位置不同的目录中找到我的mvm4x4_amf可执行文件!我看对了吗?我应该担心吗?
哦,供参考:
$ stack --version
Version 2.1.3, Git revision 0fa51b9925decd937e4a993ad90cb686f88fa282 (7739 commits) x86_64 hpack-0.31.2发布于 2020-04-05 19:40:18
啊哈!你必须这样做:
$ stack exec --profile mvm4x4_amf --rts-options -sstderr使用该命令,我将获得预期的分析结果:
294,885,845,152 bytes allocated in the heap
3,900,063,256 bytes copied during GC
160,061,616 bytes maximum residency (57 sample(s))
6,223,696 bytes maximum slop
152 MB total memory in use (0 MB lost due to fragmentation)
Tot time (elapsed) Avg pause Max pause
Gen 0 282964 colls, 0 par 6.696s 6.863s 0.0000s 0.0013s
Gen 1 57 colls, 0 par 0.928s 1.048s 0.0184s 0.1195s
INIT time 0.000s ( 0.003s elapsed)
MUT time 217.655s (221.658s elapsed)
GC time 7.624s ( 7.911s elapsed)
RP time 0.000s ( 0.000s elapsed)
PROF time 0.000s ( 0.000s elapsed)
EXIT time 0.000s ( 0.000s elapsed)
Total time 225.279s (229.571s elapsed)
%GC time 0.0% (0.0% elapsed)
Alloc rate 1,354,833,854 bytes per MUT second
Productivity 96.6% of total user, 96.6% of total elapsed在我正常的程序输出之后。
此外,还:
$ stack exec --profile which mvm4x4_amf
.../.stack-work/install/x86_64-osx/2428dc603454d346facf6484280fa92531e4d7789d33c4dd56c39cf70d79bd7e/
8.6.5/bin/mvm4x4_amf 所以,我想,--profile选项“引导”stack exec命令到一个不同的install/子目录?我想这是有道理的。
发布于 2020-04-08 10:18:00
$ stack mvm4x4_amf +RTS -sstderr mvm4x4_amf:大多数RTS选项被禁用。链接到-rtsopts以启用它们。$ stack profile -- mvm4x4_amf +RTS -sstderr可执行,名为mvm4x4_amf,在路径上找不到:{snip}
这是因为使用和不使用分析信息构建的可执行文件实际上是非常不同的可执行文件。这是因为发出分析信息非常昂贵,因此可以明显地减慢执行速度,所以当您在不使用--profile的情况下构建时,所有这些额外的代码都会被删除以提高性能。
您的第二次调用失败了,因为您没有为您的程序构建分析可执行文件。简单地说,.stack-work中有多个目录,其中包含多组二进制文件,这些二进制文件是用不同的选项构建的,所以stack exec --profile在“分析二进制文件”目录中查找,这个目录在您的示例中是空的。
在用:堆栈构建-配置文件重新构建我的Stack项目之后,我得到: $ stack profile -- mvm4x4_amf +RTS -sstderr mvm4x4_amf:大多数RTS选项被禁用。链接到-rtsopts以启用它们。
这个调用是正确的。正如错误提示的那样,您现在需要使用-rtsopts构建可执行文件,以使您的可执行文件接受要传递给它的RTS选项。
如果我用这个代替: $ stack profile mvm4x4_amf +RTS -sstderr 他们是我的程序运行,但我没有得到任何分析信息输出。
这里的问题是,stack本身就是一个Haskell问题,所以您的+RTS -sstderr选项被stack占用,而不是传递给二进制文件。您绝对需要那些-- (或者,您也可以使用--rts-options <options>,它告诉堆栈将+RTS <options>传递给二进制文件)。
https://stackoverflow.com/questions/61046771
复制相似问题