Skip to content

Make reloading of routes optional#4053

Merged
lucasmazza merged 1 commit into
heartcombo:masterfrom
sidonath:make-route-reloading-configurable
May 5, 2016
Merged

Make reloading of routes optional#4053
lucasmazza merged 1 commit into
heartcombo:masterfrom
sidonath:make-route-reloading-configurable

Conversation

@sidonath
Copy link
Copy Markdown
Contributor

@sidonath sidonath commented Apr 21, 2016

In #3153 we've seen that some applications require routes to be loaded before the code is eagerly loaded so we can't just remove it. However, this implies that all applications using Devise need to have routes reloaded twice (as was mentioned in #3241 (comment)). Double route reload can incur a slowdown for larger apps that have a lot of routes or a lot of controllers.

This PR strives for compromise, making the route reloading optional.

In our app, enabling this setting shaves off 15-25% of boot time in staging environment (we have more than 1500 routes).

As has been seen in a previous pull request, some applications require
routes to be loaded before the code is eagerly loaded, which implies
that all Rails applications using Devise need to have routes reloaded
twice:
heartcombo#3241

This can incur a very significant slowdown for large apps that have a
lot of routes or a lot of controllers, so reloading should be optional.
@ulissesalmeida ulissesalmeida added this to the 4.1.0 milestone Apr 22, 2016
@ulissesalmeida
Copy link
Copy Markdown
Contributor

Looks good. Any consideration? cc @lucasmazza @josevalim

Comment thread lib/devise.rb

# When false, Devise will not attempt to reload routes on eager load
mattr_accessor :reload_routes
@@reload_routes = true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our template configuration file, we should explicit set it? cc @lucasmazza

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to set it on the generated config file, but we can add a commented example explaining the purpose of the setting.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I can do it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sidonath
Copy link
Copy Markdown
Contributor Author

@lucasmazza @ulissesalmeida what do you think about making this the default value in the release after the next? There are probably much more applications that don't need routes to be reloaded than those which do.

@lucasmazza
Copy link
Copy Markdown
Contributor

@sidonath I guess we can go down this road but I'm not sure if we can push this into a 4.2.0 release - might be worth to gather some more feedback from other developers and maybe emit a warning for the upcoming change to help out the upgrade path, considering how unrelated the errors that might surface looks at first glance.

@sidonath
Copy link
Copy Markdown
Contributor Author

Makes sense 😄 Let me know if I should add something here

@ulissesalmeida
Copy link
Copy Markdown
Contributor

ulissesalmeida commented Apr 26, 2016

Hey @sidonath . You can add configuration line and a explanation about this config on the https://github.com/plataformatec/devise/blob/master/lib/generators/templates/devise.rb template file. Explaining what happens when you set true and false, when it is safe to set to false and gain the benefits of not reloading twice. What do you think?

@sidonath
Copy link
Copy Markdown
Contributor Author

Sure, will do

@lucasmazza lucasmazza modified the milestones: 4.1.0, 4.2.0 Apr 29, 2016
@lucasmazza lucasmazza merged commit e01fdba into heartcombo:master May 5, 2016
@lucasmazza
Copy link
Copy Markdown
Contributor

@sidonath thanks for the patch ❤️

I pushed the template change on db8e247.

@sidonath
Copy link
Copy Markdown
Contributor Author

sidonath commented May 5, 2016

@lucasmazza thanks for wrapping it up, and sorry about dropping the ball

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants