bootsnap 1.4.6 → 1.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +68 -0
  3. data/README.md +45 -14
  4. data/exe/bootsnap +5 -0
  5. data/ext/bootsnap/bootsnap.c +224 -61
  6. data/ext/bootsnap/extconf.rb +19 -14
  7. data/lib/bootsnap.rb +88 -15
  8. data/lib/bootsnap/cli.rb +246 -0
  9. data/lib/bootsnap/cli/worker_pool.rb +131 -0
  10. data/lib/bootsnap/compile_cache.rb +2 -2
  11. data/lib/bootsnap/compile_cache/iseq.rb +21 -7
  12. data/lib/bootsnap/compile_cache/yaml.rb +109 -40
  13. data/lib/bootsnap/load_path_cache.rb +3 -16
  14. data/lib/bootsnap/load_path_cache/cache.rb +23 -6
  15. data/lib/bootsnap/load_path_cache/change_observer.rb +1 -1
  16. data/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb +16 -4
  17. data/lib/bootsnap/load_path_cache/loaded_features_index.rb +3 -3
  18. data/lib/bootsnap/load_path_cache/path.rb +2 -2
  19. data/lib/bootsnap/load_path_cache/path_scanner.rb +50 -26
  20. data/lib/bootsnap/load_path_cache/realpath_cache.rb +5 -5
  21. data/lib/bootsnap/load_path_cache/store.rb +16 -9
  22. data/lib/bootsnap/setup.rb +1 -36
  23. data/lib/bootsnap/version.rb +1 -1
  24. metadata +14 -28
  25. data/.github/CODEOWNERS +0 -2
  26. data/.github/probots.yml +0 -2
  27. data/.gitignore +0 -17
  28. data/.rubocop.yml +0 -20
  29. data/.travis.yml +0 -21
  30. data/CODE_OF_CONDUCT.md +0 -74
  31. data/CONTRIBUTING.md +0 -21
  32. data/Gemfile +0 -9
  33. data/README.jp.md +0 -231
  34. data/Rakefile +0 -13
  35. data/bin/ci +0 -10
  36. data/bin/console +0 -15
  37. data/bin/setup +0 -8
  38. data/bin/test-minimal-support +0 -7
  39. data/bin/testunit +0 -8
  40. data/bootsnap.gemspec +0 -46
  41. data/dev.yml +0 -10
  42. data/lib/bootsnap/load_path_cache/core_ext/active_support.rb +0 -107
  43. data/shipit.rubygems.yml +0 -0
data/Rakefile DELETED
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
- require('rake/extensiontask')
3
- require('bundler/gem_tasks')
4
-
5
- gemspec = Gem::Specification.load('bootsnap.gemspec')
6
- Rake::ExtensionTask.new do |ext|
7
- ext.name = 'bootsnap'
8
- ext.ext_dir = 'ext/bootsnap'
9
- ext.lib_dir = 'lib/bootsnap'
10
- ext.gem_spec = gemspec
11
- end
12
-
13
- task(default: :compile)
data/bin/ci DELETED
@@ -1,10 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -euxo pipefail
4
-
5
- if [[ "${MINIMAL_SUPPORT-0}" -eq 1 ]]; then
6
- exec bin/test-minimal-support
7
- else
8
- rake
9
- exec bin/testunit
10
- fi
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require("bundler/setup")
5
- require("bootsnap")
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require("irb")
15
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -euxo pipefail
4
-
5
- cd test/minimal_support
6
- bundle
7
- BOOTSNAP_CACHE_DIR=/tmp bundle exec ruby -w -I ../../lib bootsnap_setup.rb
data/bin/testunit DELETED
@@ -1,8 +0,0 @@
1
- #!/bin/bash
2
-
3
- if [[ $# -eq 0 ]]; then
4
- exec ruby -I"test" -w -e 'Dir.glob("./test/**/*_test.rb").each { |f| require f }' -- "$@"
5
- else
6
- path=$1
7
- exec ruby -I"test" -w -e "require '${path#test/}'" -- "$@"
8
- fi
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,10 +0,0 @@
1
- env:
2
- BOOTSNAP_PEDANTIC: '1'
3
-
4
- up:
5
- - ruby: 2.6.0
6
- - bundler
7
- commands:
8
- build: rake compile
9
- test: 'rake compile && exec bin/testunit'
10
- style: 'exec rubocop -D'
@@ -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
data/shipit.rubygems.yml DELETED
File without changes