分析 Rails 项目一部分的内存性能
我想测试我的 Rails 项目的一个重要库类的配置文件使用情况。它使用 ActiveRecord,因此我需要所有 Rails 依赖项来分析它。
据我所知,我需要一个修补的 ruby (rubygc),以便脚本/配置文件和脚本/基准可以跟踪内存使用情况。我尝试按照此官方指南来修补源代码ruby 1.8.6 (p399) 和 1.8.7 (p248) 的版本,但都失败并显示以下消息:
patching file gc.c
Hunk #2 succeeded at 50 with fuzz 2 (offset 2 lines).
Hunk #3 succeeded at 87 with fuzz 2 (offset 6 lines).
Hunk #4 succeeded at 153 with fuzz 1 (offset 45 lines).
Hunk #5 succeeded at 409 with fuzz 2 (offset 274 lines).
Hunk #6 FAILED at 462.
Hunk #7 FAILED at 506.
Hunk #8 FAILED at 520.
Hunk #9 FAILED at 745.
Hunk #10 FAILED at 754.
Hunk #11 FAILED at 923.
Hunk #12 succeeded at 711 (offset 46 lines).
Hunk #13 succeeded at 730 (offset 46 lines).
Hunk #14 succeeded at 766 (offset 55 lines).
Hunk #15 succeeded at 1428 (offset 87 lines).
Hunk #16 succeeded at 1492 (offset 89 lines).
Hunk #17 FAILED at 1541.
Hunk #18 FAILED at 1551.
Hunk #19 succeeded at 1571 (offset 91 lines).
Hunk #20 succeeded at 1592 (offset 91 lines).
Hunk #21 succeeded at 1601 (offset 91 lines).
Hunk #22 succeeded at 1826 (offset 108 lines).
Hunk #23 succeeded at 1843 (offset 108 lines).
Hunk #24 succeeded at 1926 (offset 108 lines).
Hunk #25 succeeded at 2118 (offset 108 lines).
Hunk #26 succeeded at 2563 (offset 100 lines).
Hunk #27 succeeded at 2611 with fuzz 1 (offset 102 lines).
Hunk #28 succeeded at 2628 (offset 102 lines).
8 out of 28 hunks FAILED -- saving rejects to file gc.c.rej
patching file intern.h
Hunk #1 succeeded at 268 (offset 15 lines).
我也尝试使用 ruby-prof,但总是收到错误“未初始化常量 RubyProf::Test”。我不知道如何使用gem“内存”,并且“memprof”和“bleak_house”都无法成功安装。
如果我运行一个修补过的红宝石,我应该没问题。但任何其他描述图书馆课程记忆的可能性都是值得欢迎的。感谢您的帮助!
I want to test the profile usage of an important library-class of my rails-project. It uses ActiveRecord so I need all rails dependencies to profile it.
As far as I know, I need a patched ruby (rubygc) so script/profile and script/benchmark can track memory usage. I tried to follow this official guide to patch the source code of ruby 1.8.6 (p399) and 1.8.7 (p248), but both fail with the following message:
patching file gc.c
Hunk #2 succeeded at 50 with fuzz 2 (offset 2 lines).
Hunk #3 succeeded at 87 with fuzz 2 (offset 6 lines).
Hunk #4 succeeded at 153 with fuzz 1 (offset 45 lines).
Hunk #5 succeeded at 409 with fuzz 2 (offset 274 lines).
Hunk #6 FAILED at 462.
Hunk #7 FAILED at 506.
Hunk #8 FAILED at 520.
Hunk #9 FAILED at 745.
Hunk #10 FAILED at 754.
Hunk #11 FAILED at 923.
Hunk #12 succeeded at 711 (offset 46 lines).
Hunk #13 succeeded at 730 (offset 46 lines).
Hunk #14 succeeded at 766 (offset 55 lines).
Hunk #15 succeeded at 1428 (offset 87 lines).
Hunk #16 succeeded at 1492 (offset 89 lines).
Hunk #17 FAILED at 1541.
Hunk #18 FAILED at 1551.
Hunk #19 succeeded at 1571 (offset 91 lines).
Hunk #20 succeeded at 1592 (offset 91 lines).
Hunk #21 succeeded at 1601 (offset 91 lines).
Hunk #22 succeeded at 1826 (offset 108 lines).
Hunk #23 succeeded at 1843 (offset 108 lines).
Hunk #24 succeeded at 1926 (offset 108 lines).
Hunk #25 succeeded at 2118 (offset 108 lines).
Hunk #26 succeeded at 2563 (offset 100 lines).
Hunk #27 succeeded at 2611 with fuzz 1 (offset 102 lines).
Hunk #28 succeeded at 2628 (offset 102 lines).
8 out of 28 hunks FAILED -- saving rejects to file gc.c.rej
patching file intern.h
Hunk #1 succeeded at 268 (offset 15 lines).
I also tried to use ruby-prof, but I always get the error "uninitialized constant RubyProf::Test". I don't know how to use the gem "memory" and neither "memprof" nor "bleak_house" could be installed successfully.
If I get a patched ruby running, I should be fine. But any other possibility to profile the memory of library classes are welcome. Thanks for helping!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也总是在使用 ruby-prof 时遇到这个错误。 profile_test_helper.rb 中存在错误。如果将第 17 行更改为“require 'ruby-prof/test'”,它应该可以工作。
http://github.com/jeremy/ruby-prof/issues#issue/ 5
I too was always getting that error with ruby-prof. There is a bug in the profile_test_helper.rb. If you change line 17 to read "require 'ruby-prof/test'" it should work.
http://github.com/jeremy/ruby-prof/issues#issue/5
如果您使用的是 Windows,您可以尝试 Ruby Memory Validator。
您还可以尝试原始的 Ruby 内存跟踪 API,其中一些其他的都是源自。这适用于任何平台 - 但您必须自己构建 Ruby(并自己从 C/C++ 调用 API)。
If you are on Windows you could try Ruby Memory Validator.
You could also try th original Ruby Memory Tracking API which some of the other ones are derived from. This works for any platform - but you'll have to build Ruby yourself (and call the API from C/C++ yourself).