如何使用 SBCL 的 SB-SPROF 分配分析?
更新:升级到 SBCL 1.0.24 解决了我的问题。 (虽然我还需要将SLIME升级到11-23-2008修订版。稳定的2006-04-20修订版以及CVS的头部似乎不适用于SBCL 1.0.24。)
SBCL 统计分析器的文档表明您还可以分析内存分配到CPU使用率。 然而,在我的一生中,我只能够分析出一个简单的 Lisp 形式。 以下是所发生情况的示例:
CL-USER> (require :sb-sprof)
("SB-SPROF")
CL-USER> (defun ! (n)
(if (= n 1)
1
(* n (! (- n 1)))))
!
CL-USER> (sb-sprof:with-profiling (:mode :alloc :loop nil :show-progress t :max-samples 100 :report :flat)
(dotimes (n 100)
(print n)
(! 10)))
===> 0 of 100 samples taken.
0
1
2
3
4
Profiler sample vector full (12 traces / 1000 samples), doubling the size
Profiler sample vector full (17 traces / 2000 samples), doubling the size
Profiler sample vector full (25 traces / 4000 samples), doubling the size
Profiler sample vector full (36 traces / 8000 samples), doubling the size
Profiler sample vector full (52 traces / 16000 samples), doubling the size
Profiler sample vector full (74 traces / 32000 samples), doubling the size
此时,它通常会挂起。
有人在这方面取得过成功吗?
Update: Upgrading to SBCL 1.0.24 fixed my problem. (Though I also needed to upgrade SLIME to the 11-23-2008 revision. The stable 2006-04-20 revision, as well as the head of CVS don't seem to work with SBCL 1.0.24.)
The documentation for the SBCL statistical profiler indicates that you can profile memory allocation in addition to CPU usage. However, for the life of me, I have not been able to get it to profile more than a trivial Lisp form. Here's an example of what happens:
CL-USER> (require :sb-sprof)
("SB-SPROF")
CL-USER> (defun ! (n)
(if (= n 1)
1
(* n (! (- n 1)))))
!
CL-USER> (sb-sprof:with-profiling (:mode :alloc :loop nil :show-progress t :max-samples 100 :report :flat)
(dotimes (n 100)
(print n)
(! 10)))
===> 0 of 100 samples taken.
0
1
2
3
4
Profiler sample vector full (12 traces / 1000 samples), doubling the size
Profiler sample vector full (17 traces / 2000 samples), doubling the size
Profiler sample vector full (25 traces / 4000 samples), doubling the size
Profiler sample vector full (36 traces / 8000 samples), doubling the size
Profiler sample vector full (52 traces / 16000 samples), doubling the size
Profiler sample vector full (74 traces / 32000 samples), doubling the size
At this point, it usually hangs.
Has anyone had success with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我有用(即没有挂起),只是你的例子消耗很少并且需要 1ms 来运行,所以你可能想要获取更多样本并传递 :LOOP T 。
Works for me (i.e. no hanging) except that your example conses very little and takes 1ms to run so you probably want to take more samples and pass :LOOP T instead.