Closed engwan closed 4 years ago
BTW, this is easy to reproduce with a new Rails 6 app.
rails new sample
derailed_benchmarks
to the Gemfilebundle exec derailed exec perf:mem
The problem happens if either Zeitwerk or Bootsnap is enabled
I tried adding this so that we actually test with the default configuration:
diff --git a/test/rails_app/config/application.rb b/test/rails_app/config/application.rb
index 236dac5..b58f9e6 100644
--- a/test/rails_app/config/application.rb
+++ b/test/rails_app/config/application.rb
@@ -13,6 +13,8 @@ require 'devise'
module Dummy
class Application < Rails::Application
+ config.load_defaults Rails.version.to_f
+
config.action_mailer.default_url_options = { host: 'localhost:3000' }
# Settings in config/environments/* take precedence over those specified here.
But it doesn't make the test fail 🤔
I see the test is doing result = `cd '#{rails_app_path}' && #{cmd}`
. I tried stepping through the code and it works when run here.
But if I manually cd to the test rails app and do bundle exec rake -f perf.rake perf:mem --trace
I can reproduce the problem.
I'm not sure why it doesn't happen within the test.
I figured it out. We need Bundler.with_clean_env
when running these rake tasks in tests because the surrounding bundler environment changes the way things are loaded and isn't really representative of running the rake task separately.
Thanks!
Thanks @schneems! Will you be doing a release soon?
It's already released in the latest version
On Tue, Mar 24, 2020 at 8:04 AM Heinrich Lee Yu notifications@github.com wrote:
Thanks @schneems https://github.com/schneems! Will you be doing a release soon?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/schneems/derailed_benchmarks/pull/170#issuecomment-603225802, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAOSYBLAYFGHBHR6FPAQM3RJCVUDANCNFSM4KZN5RZQ .
-- Richard Schneeman https://www.schneems.com he/him
@schneems I was having trouble running
perf:mem
when Zeitwerk is enabled.I'm getting an infinite loop on the
require
because Zeitwerk also patchesrequire
:It seemed to be related to how we override
require
. See:This makes it very similar to how Zeitwerk / Bootsnap overrides
require
and this prevents the infinite loop.What do you think of this change?