From 5b1332bb4d3c3aa5215b43004d1e7f6a8d376dd0 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Wed, 11 Jan 2017 14:50:42 +0100 Subject: Fully initialize routes before the first request is handled `AD::Journey::GTG::Simulator` is lazily built the first time `Journey::Router#find_routes` is invoked, which happens when the first request is served. On large applications with many routes, building the simulator can take several hundred milliseconds (~700ms for us). Triggering this initialization during the boot process reduces the impact of deploys on the application response time. --- actionpack/lib/action_dispatch/journey/route.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'actionpack/lib/action_dispatch/journey/route.rb') diff --git a/actionpack/lib/action_dispatch/journey/route.rb b/actionpack/lib/action_dispatch/journey/route.rb index f2ac4818d8..927fd369c4 100644 --- a/actionpack/lib/action_dispatch/journey/route.rb +++ b/actionpack/lib/action_dispatch/journey/route.rb @@ -73,6 +73,14 @@ module ActionDispatch @internal = internal end + def eager_load! + path.eager_load! + ast + parts + required_defaults + nil + end + def ast @decorated_ast ||= begin decorated_ast = path.ast -- cgit v1.2.3