bootsnap 1.4.6 → 1.18.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +264 -0
- data/LICENSE.txt +1 -1
- data/README.md +63 -23
- data/exe/bootsnap +5 -0
- data/ext/bootsnap/bootsnap.c +487 -171
- data/ext/bootsnap/extconf.rb +29 -15
- data/lib/bootsnap/bundler.rb +2 -1
- data/lib/bootsnap/cli/worker_pool.rb +136 -0
- data/lib/bootsnap/cli.rb +283 -0
- data/lib/bootsnap/compile_cache/iseq.rb +71 -21
- data/lib/bootsnap/compile_cache/json.rb +89 -0
- data/lib/bootsnap/compile_cache/yaml.rb +315 -41
- data/lib/bootsnap/compile_cache.rb +26 -17
- data/lib/bootsnap/explicit_require.rb +4 -3
- data/lib/bootsnap/load_path_cache/cache.rb +72 -36
- data/lib/bootsnap/load_path_cache/change_observer.rb +24 -3
- data/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb +26 -82
- data/lib/bootsnap/load_path_cache/core_ext/loaded_features.rb +1 -0
- data/lib/bootsnap/load_path_cache/loaded_features_index.rb +38 -27
- data/lib/bootsnap/load_path_cache/path.rb +41 -19
- data/lib/bootsnap/load_path_cache/path_scanner.rb +60 -29
- data/lib/bootsnap/load_path_cache/store.rb +64 -24
- data/lib/bootsnap/load_path_cache.rb +40 -38
- data/lib/bootsnap/setup.rb +2 -36
- data/lib/bootsnap/version.rb +2 -1
- data/lib/bootsnap.rb +140 -36
- metadata +15 -99
- data/.github/CODEOWNERS +0 -2
- data/.github/probots.yml +0 -2
- data/.gitignore +0 -17
- data/.rubocop.yml +0 -20
- data/.travis.yml +0 -21
- data/CODE_OF_CONDUCT.md +0 -74
- data/CONTRIBUTING.md +0 -21
- data/Gemfile +0 -9
- data/README.jp.md +0 -231
- data/Rakefile +0 -13
- data/bin/ci +0 -10
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/bin/test-minimal-support +0 -7
- data/bin/testunit +0 -8
- data/bootsnap.gemspec +0 -46
- data/dev.yml +0 -10
- data/lib/bootsnap/load_path_cache/core_ext/active_support.rb +0 -107
- data/lib/bootsnap/load_path_cache/realpath_cache.rb +0 -32
- data/shipit.rubygems.yml +0 -0
data/bootsnap.gemspec
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
lib = File.expand_path('../lib', __FILE__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require('bootsnap/version')
|
6
|
-
|
7
|
-
Gem::Specification.new do |spec|
|
8
|
-
spec.name = "bootsnap"
|
9
|
-
spec.version = Bootsnap::VERSION
|
10
|
-
spec.authors = ["Burke Libbey"]
|
11
|
-
spec.email = ["burke.libbey@shopify.com"]
|
12
|
-
|
13
|
-
spec.license = "MIT"
|
14
|
-
|
15
|
-
spec.summary = "Boot large ruby/rails apps faster"
|
16
|
-
spec.description = spec.summary
|
17
|
-
spec.homepage = "https://github.com/Shopify/bootsnap"
|
18
|
-
|
19
|
-
spec.metadata = {
|
20
|
-
'bug_tracker_uri' => 'https://github.com/Shopify/bootsnap/issues',
|
21
|
-
'changelog_uri' => 'https://github.com/Shopify/bootsnap/blob/master/CHANGELOG.md',
|
22
|
-
'source_code_uri' => 'https://github.com/Shopify/bootsnap',
|
23
|
-
}
|
24
|
-
|
25
|
-
spec.files = %x(git ls-files -z).split("\x0").reject do |f|
|
26
|
-
f.match(%r{^(test|spec|features)/})
|
27
|
-
end
|
28
|
-
spec.require_paths = %w(lib)
|
29
|
-
|
30
|
-
spec.required_ruby_version = '>= 2.3.0'
|
31
|
-
|
32
|
-
if RUBY_PLATFORM =~ /java/
|
33
|
-
spec.platform = 'java'
|
34
|
-
else
|
35
|
-
spec.platform = Gem::Platform::RUBY
|
36
|
-
spec.extensions = ['ext/bootsnap/extconf.rb']
|
37
|
-
end
|
38
|
-
|
39
|
-
spec.add_development_dependency("bundler")
|
40
|
-
spec.add_development_dependency('rake', '~> 10.0')
|
41
|
-
spec.add_development_dependency('rake-compiler', '~> 0')
|
42
|
-
spec.add_development_dependency("minitest", "~> 5.0")
|
43
|
-
spec.add_development_dependency("mocha", "~> 1.2")
|
44
|
-
|
45
|
-
spec.add_runtime_dependency("msgpack", "~> 1.0")
|
46
|
-
end
|
data/dev.yml
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Bootsnap
|
3
|
-
module LoadPathCache
|
4
|
-
module CoreExt
|
5
|
-
module ActiveSupport
|
6
|
-
def self.without_bootsnap_cache
|
7
|
-
prev = Thread.current[:without_bootsnap_cache] || false
|
8
|
-
Thread.current[:without_bootsnap_cache] = true
|
9
|
-
yield
|
10
|
-
ensure
|
11
|
-
Thread.current[:without_bootsnap_cache] = prev
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.allow_bootsnap_retry(allowed)
|
15
|
-
prev = Thread.current[:without_bootsnap_retry] || false
|
16
|
-
Thread.current[:without_bootsnap_retry] = !allowed
|
17
|
-
yield
|
18
|
-
ensure
|
19
|
-
Thread.current[:without_bootsnap_retry] = prev
|
20
|
-
end
|
21
|
-
|
22
|
-
module ClassMethods
|
23
|
-
def autoload_paths=(o)
|
24
|
-
super
|
25
|
-
Bootsnap::LoadPathCache.autoload_paths_cache.reinitialize(o)
|
26
|
-
end
|
27
|
-
|
28
|
-
def search_for_file(path)
|
29
|
-
return super if Thread.current[:without_bootsnap_cache]
|
30
|
-
begin
|
31
|
-
Bootsnap::LoadPathCache.autoload_paths_cache.find(path)
|
32
|
-
rescue Bootsnap::LoadPathCache::ReturnFalse
|
33
|
-
nil # doesn't really apply here
|
34
|
-
rescue Bootsnap::LoadPathCache::FallbackScan
|
35
|
-
nil # doesn't really apply here
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def autoloadable_module?(path_suffix)
|
40
|
-
Bootsnap::LoadPathCache.autoload_paths_cache.load_dir(path_suffix)
|
41
|
-
end
|
42
|
-
|
43
|
-
def remove_constant(const)
|
44
|
-
CoreExt::ActiveSupport.without_bootsnap_cache { super }
|
45
|
-
end
|
46
|
-
|
47
|
-
def require_or_load(*)
|
48
|
-
CoreExt::ActiveSupport.allow_bootsnap_retry(true) do
|
49
|
-
super
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# If we can't find a constant using the patched implementation of
|
54
|
-
# search_for_file, try again with the default implementation.
|
55
|
-
#
|
56
|
-
# These methods call search_for_file, and we want to modify its
|
57
|
-
# behaviour. The gymnastics here are a bit awkward, but it prevents
|
58
|
-
# 200+ lines of monkeypatches.
|
59
|
-
def load_missing_constant(from_mod, const_name)
|
60
|
-
CoreExt::ActiveSupport.allow_bootsnap_retry(false) do
|
61
|
-
super
|
62
|
-
end
|
63
|
-
rescue NameError => e
|
64
|
-
raise(e) if e.instance_variable_defined?(Bootsnap::LoadPathCache::ERROR_TAG_IVAR)
|
65
|
-
e.instance_variable_set(Bootsnap::LoadPathCache::ERROR_TAG_IVAR, true)
|
66
|
-
|
67
|
-
# This function can end up called recursively, we only want to
|
68
|
-
# retry at the top-level.
|
69
|
-
raise(e) if Thread.current[:without_bootsnap_retry]
|
70
|
-
# If we already had cache disabled, there's no use retrying
|
71
|
-
raise(e) if Thread.current[:without_bootsnap_cache]
|
72
|
-
# NoMethodError is a NameError, but we only want to handle actual
|
73
|
-
# NameError instances.
|
74
|
-
raise(e) unless e.class == NameError
|
75
|
-
# We can only confidently handle cases when *this* constant fails
|
76
|
-
# to load, not other constants referred to by it.
|
77
|
-
raise(e) unless e.name == const_name
|
78
|
-
# If the constant was actually loaded, something else went wrong?
|
79
|
-
raise(e) if from_mod.const_defined?(const_name)
|
80
|
-
CoreExt::ActiveSupport.without_bootsnap_cache { super }
|
81
|
-
end
|
82
|
-
|
83
|
-
# Signature has changed a few times over the years; easiest to not
|
84
|
-
# reiterate it with version polymorphism here...
|
85
|
-
def depend_on(*)
|
86
|
-
super
|
87
|
-
rescue LoadError => e
|
88
|
-
raise(e) if e.instance_variable_defined?(Bootsnap::LoadPathCache::ERROR_TAG_IVAR)
|
89
|
-
e.instance_variable_set(Bootsnap::LoadPathCache::ERROR_TAG_IVAR, true)
|
90
|
-
|
91
|
-
# If we already had cache disabled, there's no use retrying
|
92
|
-
raise(e) if Thread.current[:without_bootsnap_cache]
|
93
|
-
CoreExt::ActiveSupport.without_bootsnap_cache { super }
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
module ActiveSupport
|
102
|
-
module Dependencies
|
103
|
-
class << self
|
104
|
-
prepend(Bootsnap::LoadPathCache::CoreExt::ActiveSupport::ClassMethods)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Bootsnap
|
4
|
-
module LoadPathCache
|
5
|
-
class RealpathCache
|
6
|
-
def initialize
|
7
|
-
@cache = Hash.new { |h, k| h[k] = realpath(*k) }
|
8
|
-
end
|
9
|
-
|
10
|
-
def call(*key)
|
11
|
-
@cache[key]
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def realpath(caller_location, path)
|
17
|
-
base = File.dirname(caller_location)
|
18
|
-
file = find_file(File.expand_path(path, base))
|
19
|
-
dir = File.dirname(file)
|
20
|
-
File.join(dir, File.basename(file))
|
21
|
-
end
|
22
|
-
|
23
|
-
def find_file(name)
|
24
|
-
['', *CACHED_EXTENSIONS].each do |ext|
|
25
|
-
filename = "#{name}#{ext}"
|
26
|
-
return File.realpath(filename) if File.exist?(filename)
|
27
|
-
end
|
28
|
-
name
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/shipit.rubygems.yml
DELETED
File without changes
|