bootsnap 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.jp.md +4 -4
- data/lib/bootsnap.rb +5 -1
- data/lib/bootsnap/load_path_cache/cache.rb +0 -8
- data/lib/bootsnap/load_path_cache/change_observer.rb +26 -29
- data/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb +1 -51
- data/lib/bootsnap/load_path_cache/path_scanner.rb +7 -15
- data/lib/bootsnap/setup.rb +1 -1
- data/lib/bootsnap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc93ed69fb2f50721ee3edbd37bf5f44a617db15ad1d77cf3a675197d7b420e6
|
4
|
+
data.tar.gz: 370a02dfb9fcb85d3c38ffa26c5ac89720e6ac493f9cb90262da2b096e2f0457
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14aee751c568fa870b4c8f694274108460a99605b32e355dfa73d25070609c06a0a9531a00f0fe66ea261428c9c0379ff39813168ffa233a5209c39e72f92779
|
7
|
+
data.tar.gz: e6d2bd977b56bdc5b46d7a335f3f4fef729747527dce035233f2f590c22bb88fe35d79dae68de191ff83cb98fcb7b8a0275639b3a6bc44697c26a3bed5af1b85
|
data/CHANGELOG.md
CHANGED
data/README.jp.md
CHANGED
@@ -56,11 +56,11 @@ Bootsnapのすべての機能はセットアップ時の設定に従って開発
|
|
56
56
|
Bootsnap は、処理に時間のかかるメソッドの結果をキャッシュすることで最適化しています。これは、大きく分けて2つのカテゴリに分けられます。
|
57
57
|
|
58
58
|
* [Path Pre-Scanning](#path-pre-scanning)
|
59
|
-
|
60
|
-
|
59
|
+
* `Kernel#require` と `Kernel#load` を `$LOAD_PATH` フルスキャンを行わないように変更します。
|
60
|
+
* `ActiveSupport::Dependencies.{autoloadable_module?,load_missing_constant,depend_on}` を `ActiveSupport::Dependencies.autoload_paths` のフルスキャンを行わないようにオーバーライドします。
|
61
61
|
* [Compilation caching](#compilation-caching)
|
62
|
-
|
63
|
-
|
62
|
+
* Ruby バイトコードのコンパイル結果をキャッシュするためのメソッド `RubyVM::InstructionSequence.load_iseq` が実装されています。
|
63
|
+
* `YAML.load_file` を YAML オブジェクトのロード結果を MessagePack でキャッシュするように変更します。 MessagePack でサポートされていないタイプが使われている場合は Marshal が使われます。
|
64
64
|
|
65
65
|
### Path Pre-Scanning
|
66
66
|
|
data/lib/bootsnap.rb
CHANGED
@@ -35,6 +35,10 @@ module Bootsnap
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def self.setup_disable_trace
|
38
|
-
|
38
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.5.0')
|
39
|
+
warn("This method is not allowed with this Ruby version. current: #{RUBY_VERSION}, allowed version: < 2.5.0")
|
40
|
+
else
|
41
|
+
RubyVM::InstructionSequence.compile_option = { trace_instruction: false }
|
42
|
+
end
|
39
43
|
end
|
40
44
|
end
|
@@ -103,14 +103,6 @@ module Bootsnap
|
|
103
103
|
@mutex.synchronize { push_paths_locked(*paths) }
|
104
104
|
end
|
105
105
|
|
106
|
-
def each_requirable
|
107
|
-
@mutex.synchronize do
|
108
|
-
@index.each do |rel, entry|
|
109
|
-
yield "#{entry}/#{rel}"
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
106
|
def reinitialize(path_obj = @path_obj)
|
115
107
|
@mutex.synchronize do
|
116
108
|
@path_obj = path_obj
|
@@ -1,37 +1,28 @@
|
|
1
1
|
module Bootsnap
|
2
2
|
module LoadPathCache
|
3
3
|
module ChangeObserver
|
4
|
-
|
5
|
-
# Re-overriding these methods on an array that already has them would
|
6
|
-
# cause StackOverflowErrors
|
7
|
-
return if arr.respond_to?(:push_without_lpc)
|
8
|
-
|
4
|
+
module ArrayMixin
|
9
5
|
# For each method that adds items to one end or another of the array
|
10
6
|
# (<<, push, unshift, concat), override that method to also notify the
|
11
7
|
# observer of the change.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
observer.push_paths(self, entry.to_s)
|
16
|
-
shovel_without_lpc(entry)
|
8
|
+
def <<(entry)
|
9
|
+
@lpc_observer.push_paths(self, entry.to_s)
|
10
|
+
super
|
17
11
|
end
|
18
12
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
push_without_lpc(*entries)
|
13
|
+
def push(*entries)
|
14
|
+
@lpc_observer.push_paths(self, *entries.map(&:to_s))
|
15
|
+
super
|
23
16
|
end
|
24
17
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
unshift_without_lpc(*entries)
|
18
|
+
def unshift(*entries)
|
19
|
+
@lpc_observer.unshift_paths(self, *entries.map(&:to_s))
|
20
|
+
super
|
29
21
|
end
|
30
22
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
concat_without_lpc(entries)
|
23
|
+
def concat(entries)
|
24
|
+
@lpc_observer.push_paths(self, *entries.map(&:to_s))
|
25
|
+
super
|
35
26
|
end
|
36
27
|
|
37
28
|
# For each method that modifies the array more aggressively, override
|
@@ -41,16 +32,22 @@ module Bootsnap
|
|
41
32
|
# accounting cost would be greater than the hit from these, since we
|
42
33
|
# actively discourage calling them.
|
43
34
|
%i(
|
44
|
-
collect! compact! delete delete_at delete_if fill flatten!
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
35
|
+
[]= clear collect! compact! delete delete_at delete_if fill flatten!
|
36
|
+
insert keep_if map! pop reject! replace reverse! rotate! select!
|
37
|
+
shift shuffle! slice! sort! sort_by! uniq!
|
38
|
+
).each do |method_name|
|
39
|
+
define_method(method_name) do |*args, &block|
|
40
|
+
ret = super(*args, &block)
|
41
|
+
@lpc_observer.reinitialize
|
42
|
+
ret
|
51
43
|
end
|
52
44
|
end
|
53
45
|
end
|
46
|
+
|
47
|
+
def self.register(observer, arr)
|
48
|
+
arr.instance_variable_set(:@lpc_observer, observer)
|
49
|
+
arr.extend(ArrayMixin)
|
50
|
+
end
|
54
51
|
end
|
55
52
|
end
|
56
53
|
end
|
@@ -11,7 +11,7 @@ module Bootsnap
|
|
11
11
|
end
|
12
12
|
|
13
13
|
module Kernel
|
14
|
-
|
14
|
+
module_function
|
15
15
|
|
16
16
|
alias_method :require_without_bootsnap, :require
|
17
17
|
|
@@ -63,56 +63,6 @@ module Kernel
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
class << Kernel
|
67
|
-
alias_method :require_without_bootsnap, :require
|
68
|
-
|
69
|
-
def require_with_bootsnap_lfi(path, resolved = nil)
|
70
|
-
Bootsnap::LoadPathCache.loaded_features_index.register(path, resolved) do
|
71
|
-
require_without_bootsnap(resolved || path)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def require(path)
|
76
|
-
return false if Bootsnap::LoadPathCache.loaded_features_index.key?(path)
|
77
|
-
|
78
|
-
if resolved = Bootsnap::LoadPathCache.load_path_cache.find(path)
|
79
|
-
return require_with_bootsnap_lfi(path, resolved)
|
80
|
-
end
|
81
|
-
|
82
|
-
raise Bootsnap::LoadPathCache::CoreExt.make_load_error(path)
|
83
|
-
rescue Bootsnap::LoadPathCache::ReturnFalse
|
84
|
-
return false
|
85
|
-
rescue Bootsnap::LoadPathCache::FallbackScan
|
86
|
-
require_with_bootsnap_lfi(path)
|
87
|
-
end
|
88
|
-
|
89
|
-
alias_method :require_relative_without_bootsnap, :require_relative
|
90
|
-
def require_relative(path)
|
91
|
-
realpath = Bootsnap::LoadPathCache.realpath_cache.call(
|
92
|
-
caller_locations(1..1).first.absolute_path, path
|
93
|
-
)
|
94
|
-
require(realpath)
|
95
|
-
end
|
96
|
-
|
97
|
-
alias_method :load_without_bootsnap, :load
|
98
|
-
def load(path, wrap = false)
|
99
|
-
if resolved = Bootsnap::LoadPathCache.load_path_cache.find(path)
|
100
|
-
return load_without_bootsnap(resolved, wrap)
|
101
|
-
end
|
102
|
-
|
103
|
-
# load also allows relative paths from pwd even when not in $:
|
104
|
-
if File.exist?(relative = File.expand_path(path))
|
105
|
-
return load_without_bootsnap(relative, wrap)
|
106
|
-
end
|
107
|
-
|
108
|
-
raise Bootsnap::LoadPathCache::CoreExt.make_load_error(path)
|
109
|
-
rescue Bootsnap::LoadPathCache::ReturnFalse
|
110
|
-
return false
|
111
|
-
rescue Bootsnap::LoadPathCache::FallbackScan
|
112
|
-
load_without_bootsnap(path, wrap)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
66
|
class Module
|
117
67
|
alias_method :autoload_without_bootsnap, :autoload
|
118
68
|
def autoload(const, path)
|
@@ -3,16 +3,8 @@ require_relative '../explicit_require'
|
|
3
3
|
module Bootsnap
|
4
4
|
module LoadPathCache
|
5
5
|
module PathScanner
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
# * `/*{.rb,.so,/}` - It matches requirable files, directories and
|
10
|
-
# symlinks to directories at given path.
|
11
|
-
# * `/*/**/*{.rb,.so,/}` - It matches requirable files and
|
12
|
-
# subdirectories in any (even symlinked) directory at given path at
|
13
|
-
# any directory tree depth.
|
14
|
-
#
|
15
|
-
REQUIRABLES_AND_DIRS = "/{,*/**/}*{#{DOT_RB},#{DL_EXTENSIONS.join(',')},/}"
|
6
|
+
ALL_FILES = "/{,**/*/**/}*"
|
7
|
+
REQUIRABLE_EXTENSIONS = [DOT_RB] + DL_EXTENSIONS
|
16
8
|
NORMALIZE_NATIVE_EXTENSIONS = !DL_EXTENSIONS.include?(LoadPathCache::DOT_SO)
|
17
9
|
ALTERNATIVE_NATIVE_EXTENSIONS_PATTERN = /\.(o|bundle|dylib)\z/
|
18
10
|
BUNDLE_PATH = Bootsnap.bundler? ?
|
@@ -34,13 +26,13 @@ module Bootsnap
|
|
34
26
|
dirs = []
|
35
27
|
requirables = []
|
36
28
|
|
37
|
-
Dir.glob(path +
|
29
|
+
Dir.glob(path + ALL_FILES).each do |absolute_path|
|
38
30
|
next if contains_bundle_path && absolute_path.start_with?(BUNDLE_PATH)
|
39
|
-
relative_path = absolute_path.slice
|
31
|
+
relative_path = absolute_path.slice(relative_slice)
|
40
32
|
|
41
|
-
if
|
42
|
-
dirs << relative_path
|
43
|
-
|
33
|
+
if File.directory?(absolute_path)
|
34
|
+
dirs << relative_path
|
35
|
+
elsif REQUIRABLE_EXTENSIONS.include?(File.extname(relative_path))
|
44
36
|
requirables << relative_path
|
45
37
|
end
|
46
38
|
end
|
data/lib/bootsnap/setup.rb
CHANGED
@@ -3,7 +3,7 @@ require_relative '../bootsnap'
|
|
3
3
|
env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || ENV['ENV']
|
4
4
|
development_mode = ['', nil, 'development'].include?(env)
|
5
5
|
|
6
|
-
# only enable on 'ruby' (MRI), POSIX (
|
6
|
+
# only enable on 'ruby' (MRI), POSIX (darwin, linux, *bsd), and >= 2.3.0
|
7
7
|
enable_cc =
|
8
8
|
RUBY_ENGINE == 'ruby' &&
|
9
9
|
RUBY_PLATFORM =~ /darwin|linux|bsd/ &&
|
data/lib/bootsnap/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootsnap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Burke Libbey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|