From 54cad7c773c809ed6d11abcd63aa2040c1829bdb Mon Sep 17 00:00:00 2001 From: whiteleaf7 <2nd.leaf@gmail.com> Date: Tue, 18 Sep 2018 18:13:48 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Bootsnap=20=E3=82=92=E5=88=A9=E7=94=A8?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog.md | 9 +++++++++ config/bootsnap_setup.rb | 12 ++++++++++++ narou.gemspec | 1 - narou.rb | 2 ++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 config/bootsnap_setup.rb diff --git a/ChangeLog.md b/ChangeLog.md index 1cbe30b3..815373f2 100755 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,15 @@ 更新履歴 - ChangeLog ==================== +3.3.1: 2018/xx/xx +------------------ +#### 追加機能 +- 起動速度を向上させる Bootsnap を利用できるようにしました + - gem install bootsnap を実行し、環境変数 NAROU_ENABLE_BOOTSNAP に真を設定 + すると有効になります。(※Bootsnap は Windows では動作しません) + - 約20%くらい起動速度が速くなります + + 3.3.0: 2018/xx/xx ------------------ #### 追加機能 diff --git a/config/bootsnap_setup.rb b/config/bootsnap_setup.rb new file mode 100644 index 00000000..3f3b7f34 --- /dev/null +++ b/config/bootsnap_setup.rb @@ -0,0 +1,12 @@ +if ENV["NAROU_ENABLE_BOOTSNAP"] + require "bootsnap" + Bootsnap.setup( + cache_dir: "tmp/cache", + development_mode: false, + load_path_cache: true, + autoload_paths_cache: false, + disable_trace: false, + compile_cache_iseq: true, + compile_cache_yaml: true + ) +end diff --git a/narou.gemspec b/narou.gemspec index ad87823c..af671dc5 100644 --- a/narou.gemspec +++ b/narou.gemspec @@ -109,4 +109,3 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency 'activesupport', '~> 5.2' gem.add_runtime_dependency 'unicode-display_width', '~> 1.4' end - diff --git a/narou.rb b/narou.rb index b7b35171..81760cd1 100644 --- a/narou.rb +++ b/narou.rb @@ -6,6 +6,8 @@ # Copyright 2013 whiteleaf. All rights reserved. # +require_relative "config/bootsnap_setup" + require_relative "lib/extension" require_relative "lib/backtracer" From fb1ecf92b0b7d17e2640e25dfc3b583274aa24f9 Mon Sep 17 00:00:00 2001 From: whiteleaf7 <2nd.leaf@gmail.com> Date: Tue, 18 Sep 2018 22:42:12 +0900 Subject: [PATCH 2/3] add bootsnap to Gemfile --- Gemfile | 1 + Gemfile.lock | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/Gemfile b/Gemfile index 93d3ce85..86775b71 100644 --- a/Gemfile +++ b/Gemfile @@ -16,3 +16,4 @@ gem "better_errors" gem "binding_of_caller" gem "awesome_print" gem "simplecov", require: false, group: :test +gem "bootsnap", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 4b026714..08c6337b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -35,9 +35,14 @@ GEM rack (>= 0.9.0) binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) + bootsnap (1.3.2) + msgpack (~> 1.0) + bootsnap (1.3.2-java) + msgpack (~> 1.0) byebug (10.0.2) coderay (1.1.2) concurrent-ruby (1.0.5) + concurrent-ruby (1.0.5-java) debug_inspector (0.0.3) diff-lcs (1.3) docile (1.3.1) @@ -59,6 +64,8 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2018.0812) minitest (5.11.3) + msgpack (1.2.4) + msgpack (1.2.4-java) multi_json (1.13.1) open_uri_redirections (0.2.1) pony (1.12) @@ -125,6 +132,7 @@ GEM systemu (2.6.5) termcolorlight (1.1.1) thread_safe (0.3.6) + thread_safe (0.3.6-java) tilt (2.0.8) timecop (0.9.1) tzinfo (1.2.5) @@ -139,6 +147,7 @@ DEPENDENCIES awesome_print better_errors binding_of_caller + bootsnap narou! pry pry-byebug From a243d440b017724683b0f3d5e26c62bb4e5581be Mon Sep 17 00:00:00 2001 From: whiteleaf7 <2nd.leaf@gmail.com> Date: Tue, 18 Sep 2018 22:45:28 +0900 Subject: [PATCH 3/3] lint --- .rubocop.yml | 3 +++ config/bootsnap_setup.rb | 2 ++ 2 files changed, 5 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 435f1786..3dff3df5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -238,3 +238,6 @@ Lint/EmptyWhen: Style/FormatStringToken: EnforcedStyle: unannotated + +Bundler/OrderedGems: + Enabled: false diff --git a/config/bootsnap_setup.rb b/config/bootsnap_setup.rb index 3f3b7f34..4f19994b 100644 --- a/config/bootsnap_setup.rb +++ b/config/bootsnap_setup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + if ENV["NAROU_ENABLE_BOOTSNAP"] require "bootsnap" Bootsnap.setup(