From 0312a5c67e35b960e33677b5358c539f1047e4e1 Mon Sep 17 00:00:00 2001 From: Burke Libbey Date: Thu, 1 Jun 2017 14:28:51 -0400 Subject: [PATCH] Add bootsnap to default Gemfile: Bootsnap precomputes load path resolution and caches ruby ISeq and YAML parsing/compilation, reducing application boot time by approximately 50% on supported configurations. --- Gemfile | 3 +++ Gemfile.lock | 4 ++++ railties/CHANGELOG.md | 4 ++++ railties/lib/rails/generators/rails/app/templates/Gemfile | 3 +++ .../lib/rails/generators/rails/app/templates/config/boot.rb | 1 + 5 files changed, 15 insertions(+) diff --git a/Gemfile b/Gemfile index 1fbf223d64..ccf73206b1 100644 --- a/Gemfile +++ b/Gemfile @@ -54,6 +54,9 @@ gem "libxml-ruby", platforms: :ruby # Action View. For testing Erubis handler deprecation. gem "erubis", "~> 2.7.0", require: false +# for railties app_generator_test +gem "bootsnap", ">= 1.1.0", require: false + # Active Job. group :job do gem "resque", require: false diff --git a/Gemfile.lock b/Gemfile.lock index f06b9a32f2..86d1bf90c3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -119,6 +119,8 @@ GEM childprocess faraday selenium-webdriver + bootsnap (1.1.0) + msgpack (~> 1.0) builder (3.2.3) bunny (2.6.2) amq-protocol (>= 2.0.1) @@ -217,6 +219,7 @@ GEM mocha (0.14.0) metaclass (~> 0.0.1) mono_logger (1.1.0) + msgpack (1.1.0) multi_json (1.12.1) multipart-post (2.0.0) mustache (1.0.3) @@ -384,6 +387,7 @@ DEPENDENCIES benchmark-ips blade blade-sauce_labs_plugin + bootsnap (>= 1.1.0) byebug capybara (~> 2.13) coffee-rails diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index db55d4fd69..f720b7caab 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* Add `bootsnap` to default `Gemfile`. + + *Burke Libbey* + * Properly expand shortcuts for environment's name running the `console` and `dbconsole` commands. diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index 64e2062aea..f49b503f85 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -19,6 +19,9 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } # Use Capistrano for deployment # gem 'capistrano-rails', group: :development +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + <%- if options.api? -%> # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible # gem 'rack-cors' diff --git a/railties/lib/rails/generators/rails/app/templates/config/boot.rb b/railties/lib/rails/generators/rails/app/templates/config/boot.rb index 30f5120df6..b9e460cef3 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/boot.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/boot.rb @@ -1,3 +1,4 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. -- GitLab