DEV: add routes_lazy_route to boost boot-up time (PR #14545)

The lazy route initialization cuts down boot time of rails.

On my local system it cuts out 200ms of boot time taking me from 3.2 to 3 seconds.

This is not a radically enormous amount of time, but paper cuts add up, and a faster boot in dev will make everyone happy.

TBD if we want to also include this in production.

Gem is heavily maintained by @amatsuda, last commit 3 days ago.


TBD if we want to also include this in production.

In production routes are preloaded in Unicorn master and we definitely do not want to be deferring the loading of routes to the first request.

Tests are failing but I looked through what the gem is doing and am comfortable with it. It is monkey patching Rails but not really in alot of spots to no big deal.

The hotspot around loading routes is here rails/routes_reloader.rb at ab3c1c6e5ee3e995661b75e12d8de801f682cd7f · rails/rails · GitHub

Yeah but would be sort of nice to make rake tasks and rail console etc a bit faster

This reminds me of my PR to rails to Rails which never got merged. In production, we’re allocating a whole bunch of strings because we have an I18n reloader which is grabbing the mtime of each translation file in production even though we never ever need a file watcher in production.

1 Like

“NameError: uninitialized constant Sidekiq::ScheduledSet”

I guess our routes.rb file is forcing certain things to load …

Looks like we were loading sidekiq in development via require 'sidekiq/web' so now that this is deferred, we need to require sidekiq/api here.

1 Like

looks good!