无法安装新版本的 jemalloc gem(在 heroku 上工作)

Cannot install new versions of jemalloc gem (to work on heroku)

我的 Ruby 在 Rails 应用程序 (ruby 2.3.3, rails 4.2.10) 上的内存问题已经有一段时间了,我想尝试 gem jemalloc 以及 buildpack heroku-buildpack-jemalloc 因为它似乎对其他人有很大帮助。

如果我只添加:

gem 'jemalloc' 

在我的 Gemfile 和 运行 bundle install 中它可以工作,但我得到的版本 1.0.1 是 rubygems.org 上的最新版本。在(成功)在 Heroku 上安装 buildpack 后,我尝试上传我的应用程序,但失败并显示

remote:  !
remote:  !     Could not detect rake tasks
remote:  !     ensure you can run `$ bundle exec rake -P` against your app
remote:  !     and using the production group of your Gemfile.
remote:  !     rake aborted!
remote:  !     LoadError: /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/jemalloc-1.0.1/lib/jemalloc.so: undefined symbol: Init_jemalloc - /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/jemalloc-1.0.1/lib/jemalloc.so
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:82:in `require'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:82:in `block (2 levels) in require'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:77:in `each'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:77:in `block in require'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:66:in `each'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:66:in `require'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.2/lib/bundler.rb:108:in `require'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/config/application.rb:7:in `<top (required)>'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/Rakefile:4:in `require'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/Rakefile:4:in `<top (required)>'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/rake-12.3.3/lib/rake/rake_module.rb:29:in `load'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/rake-12.3.3/lib/rake/rake_module.rb:29:in `load_rakefile'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/rake-12.3.3/lib/rake/application.rb:703:in `raw_load_rakefile'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/rake-12.3.3/lib/rake/application.rb:104:in `block in load_rakefile'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/rake-12.3.3/lib/rake/application.rb:103:in `load_rakefile'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/rake-12.3.3/lib/rake/application.rb:82:in `block in run'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/rake-12.3.3/lib/rake/application.rb:80:in `run'
remote:  !     /tmp/build_c49fb2d1484e39d9a1e11c3b732d5119/vendor/bundle/ruby/2.3.0/gems/rake-12.3.3/exe/rake:27:in `<top (required)>'
remote:  !     vendor/bundle/bin/rake:17:in `load'
remote:  !     vendor/bundle/bin/rake:17:in `<main>' 

考虑到 rubygems.org 上的最新版本 1.0.1(从我获得所有其他 gem 的地方)是 2015 年的,据我所知 gem (https://github.com/jemalloc/jemalloc) 是 5.1.0 (?) 现在似乎 rubygems.org 由于某种原因没有最新版本。为什么,我想知道?

我假设这就是我推送到 heroku 无法正常工作的原因,因为 buildpack 似乎至少需要 3.x 版本的 jemalloc 才能工作,而不是我在 [=46] 上可以找到的古老版本=]

因此,我尝试使用以下方法直接从 github 下载 gem:

gem 'jemalloc' , :git => "https://github.com/jemalloc/jemalloc.git"

然后是运行bundle install。这导致:

Fetching https://github.com/jemalloc/jemalloc.git
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/.
Could not find gem 'jemalloc' in https://github.com/jemalloc/jemalloc.git (at master@ea6b3e9).
The source does not contain any versions of 'jemalloc'

令我惊讶的是。我不明白为什么这不起作用。

所以,我剩下的版本 1.0.1(我假设)不能与我在 Heroku 上需要的构建包一起使用。

我如何捆绑更新版本的 jemalloc 以使其工作?我错过了什么?

我还发现有关 jemalloc 的信息被包含在 ruby 2.2.0 中,这是否意味着它可能已经在我的应用程序中使用了?我没有在我的 Rails 应用程序中对此进行任何配置。

最后,我只对在 Heroku 上的实时生产应用程序中使用 jemalloc 感兴趣,而不是在笔记本电脑上本地开发版本中使用 jemalloc。

您引用的 link 不是 gem 的存储库,因此您收到消息是有道理的:"Could not find gem 'jemalloc'"。

我认为您不需要 gem。尝试使用这个 heroku buildpack。确保设置 heroku 环境变量:JEMALLOC_ENABLED = true and JEMALLOC_VERSION = 5.2.0