bootsnap 1.0.0 → 1.1.0.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 77b33ef59e01f0ddaa1de86a002ce286018b870d
4
- data.tar.gz: 958ec1e45c50803261866ade91f9300dd6975d03
3
+ metadata.gz: eb4f1c7a20afd5550cb29063940865fa1b7cf1a6
4
+ data.tar.gz: 1309c503d7c4fedbd07a30efc8fbe1cdb7fd44c7
5
5
  SHA512:
6
- metadata.gz: bcb190169610158178bff1fbf16ed6d43a4f986d06c7e07c16c5199aa658512749490b43e42b1e2e431a1099aa5ebd50e5905a35a0170f75e2cc2d468037eca1
7
- data.tar.gz: 17fe5e20e585fce572bc39a47febe146abba4ec0aea70934c9d39f88fd271f158b3dd0fc3b0fe103e3060c97ade3bd890cf9e74d28f7ba4fb6b7836a401dac14
6
+ metadata.gz: 712729db38aedc0316e4d2043dc3eb3f72cd6560915052ee3bf9fc19de74a5c6534716d2607ac312bb074f8df529f76a9fdfd584d746356280dc96c43fb8de3c
7
+ data.tar.gz: a978d40c13d3b665910571224d378d75ec7d6c1779e8fc535bf88efc3c290e948d681f055a2ae1fcd0d6ae84df0e8ef501714c4e12c2e420357de4e7995f9dae
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 1.1.0
2
+
3
+ * Add `bootsnap/setup`
4
+ * Support jruby (without compile caching features)
5
+
1
6
  # 1.0.0
2
7
 
3
8
  * (none)
data/README.md CHANGED
@@ -20,19 +20,26 @@ Add `bootsnap` to your `Gemfile`:
20
20
  gem 'bootsnap'
21
21
  ```
22
22
 
23
- Next, add this to your boot setup immediately after `require 'bundler/setup'` (i.e. as early as
24
- possible: the sooner this is loaded, the sooner it can start optimizing things)
23
+ If you are using rails, add this to `config/boot.rb` immediately after `require 'bundler/setup'`:
24
+
25
+ ```ruby
26
+ require 'bootsnap/setup'
27
+ ```
28
+
29
+ If you are not using rails, or if you are but want more control over things, add this to your
30
+ application setup immediately after `require 'bundler/setup'` (i.e. as early as possible: the sooner
31
+ this is loaded, the sooner it can start optimizing things)
25
32
 
26
33
  ```ruby
27
34
  require 'bootsnap'
28
35
  Bootsnap.setup(
29
- cache_dir: 'tmp/cache', # Path to your cache
30
- development_mode: ENV['MY_ENV'] == 'development',
31
- load_path_cache: true, # Should we optimize the LOAD_PATH with a cache?
32
- autoload_paths_cache: true, # Should we optimize ActiveSupport autoloads with cache?
33
- disable_trace: false, # Sets `RubyVM::InstructionSequence.compile_option = { trace_instruction: false }`
34
- compile_cache_iseq: true, # Should compile Ruby code into ISeq cache?
35
- compile_cache_yaml: true # Should compile YAML into a cache?
36
+ cache_dir: 'tmp/cache', # Path to your cache
37
+ development_mode: ENV['RAILS_ENV'] == 'development', # This should be set to whatever evaluates your current working environment, e.g. RACK_ENV, RAILS_ENV, etc
38
+ load_path_cache: true, # Should we optimize the LOAD_PATH with a cache?
39
+ autoload_paths_cache: true, # Should we optimize ActiveSupport autoloads with cache?
40
+ disable_trace: false, # Sets `RubyVM::InstructionSequence.compile_option = { trace_instruction: false }`
41
+ compile_cache_iseq: true, # Should compile Ruby code into ISeq cache?
42
+ compile_cache_yaml: true # Should compile YAML into a cache?
36
43
  )
37
44
  ```
38
45
 
@@ -262,7 +269,7 @@ open /c/nope.bundle -> -1
262
269
  We use the `*_path_cache` features in production and haven't experienced any issues in a long time.
263
270
 
264
271
  The `compile_cache_*` features work well for us in development on macOS. It should work on Linux,
265
- and we intend to deploy it in production, but haven't we haven't yet.
272
+ and we intend to deploy it in production, but we haven't yet.
266
273
 
267
274
  `disable_trace` should be completely safe, but we don't really use it because some people like to
268
275
  use tools that make use of `trace` instructions.
data/bootsnap.gemspec CHANGED
@@ -18,12 +18,16 @@ Gem::Specification.new do |spec|
18
18
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
19
  f.match(%r{^(test|spec|features)/})
20
20
  end
21
- spec.bindir = "exe"
22
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
21
  spec.require_paths = ["lib"]
24
- spec.extensions = ['ext/bootsnap/extconf.rb']
25
22
 
26
- spec.required_ruby_version = '>= 2.3.0'
23
+ spec.required_ruby_version = '>= 2.0.0'
24
+
25
+ if RUBY_PLATFORM =~ /java/
26
+ spec.platform = 'java'
27
+ else
28
+ spec.platform = Gem::Platform::RUBY
29
+ spec.extensions = ['ext/bootsnap/extconf.rb']
30
+ end
27
31
 
28
32
  spec.add_development_dependency "bundler", '~> 1'
29
33
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -316,7 +316,7 @@ open_cache_file(const char * path, struct bs_cache_key * key)
316
316
  {
317
317
  int fd, res;
318
318
 
319
- fd = open(path, O_RDWR, 0644);
319
+ fd = open(path, O_RDONLY);
320
320
  if (fd < 0) {
321
321
  if (errno == ENOENT) return CACHE_MISSING_OR_INVALID;
322
322
  return ERROR_WITH_ERRNO;
@@ -1,14 +1,13 @@
1
- require_relative 'compile_cache/iseq'
2
- require_relative 'compile_cache/yaml'
3
-
4
1
  module Bootsnap
5
2
  module CompileCache
6
3
  def self.setup(cache_dir:, iseq:, yaml:)
7
4
  if iseq
5
+ require_relative 'compile_cache/iseq'
8
6
  Bootsnap::CompileCache::ISeq.install!(cache_dir)
9
7
  end
10
8
 
11
9
  if yaml
10
+ require_relative 'compile_cache/yaml'
12
11
  Bootsnap::CompileCache::YAML.install!(cache_dir)
13
12
  end
14
13
  end
@@ -1,3 +1,5 @@
1
+ require 'bootsnap/bootsnap'
2
+
1
3
  module Bootsnap
2
4
  module CompileCache
3
5
  module YAML
@@ -0,0 +1,47 @@
1
+ require_relative '../bootsnap'
2
+
3
+ env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || ENV['ENV']
4
+ development_mode = ['', nil, 'development'].include?(env)
5
+
6
+ # only enable on 'ruby' (MRI), POSIX (darin, linux, *bsd), and >= 2.3.0
7
+ enable_cc = \
8
+ RUBY_ENGINE == 'ruby' && \
9
+ RUBY_PLATFORM =~ /darwin|linux|bsd/ && \
10
+ RUBY_VERSION # "1.9.3"
11
+ .split('.') # ["1", "9", "3"]
12
+ .map(&:to_i) # [1, 9, 3]
13
+ .zip([2, 3, -1]) # [[1, 2], [9, 3], [3, -1]]
14
+ .map { |a, b| a <=> b } # [-1, 1, 1]
15
+ .detect { |e| !e.zero? } # -1
16
+ .==(1) # false
17
+
18
+ cache_dir = ENV['BOOTSNAP_CACHE_DIR']
19
+ unless cache_dir
20
+ config_dir_frame = caller.detect do |line|
21
+ line.include?('/config/')
22
+ end
23
+
24
+ unless config_dir_frame
25
+ $stderr.puts "[bootsnap/setup] couldn't infer cache directory! Either:"
26
+ $stderr.puts "[bootsnap/setup] 1. require bootsnap/setup from your application's config directory; or"
27
+ $stderr.puts "[bootsnap/setup] 2. Define the environment variable BOOTSNAP_CACHE_DIR"
28
+
29
+ raise "couldn't infer bootsnap cache directory"
30
+ end
31
+
32
+ path = config_dir_frame.split(/:\d+:/).first
33
+ path = File.dirname(path) until File.basename(path) == 'config'
34
+ app_root = File.dirname(path)
35
+
36
+ cache_dir = File.join(app_root, 'tmp', 'cache')
37
+ end
38
+
39
+ Bootsnap.setup(
40
+ cache_dir: cache_dir,
41
+ development_mode: development_mode,
42
+ load_path_cache: true,
43
+ autoload_paths_cache: true, # assume rails. open to PRs to impl. detection
44
+ disable_trace: false,
45
+ compile_cache_iseq: enable_cc,
46
+ compile_cache_yaml: enable_cc
47
+ )
@@ -1,3 +1,3 @@
1
1
  module Bootsnap
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0.pre"
3
3
  end
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.0.0
4
+ version: 1.1.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burke Libbey
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-01 00:00:00.000000000 Z
11
+ date: 2017-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -146,6 +146,7 @@ files:
146
146
  - lib/bootsnap/load_path_cache/path.rb
147
147
  - lib/bootsnap/load_path_cache/path_scanner.rb
148
148
  - lib/bootsnap/load_path_cache/store.rb
149
+ - lib/bootsnap/setup.rb
149
150
  - lib/bootsnap/version.rb
150
151
  homepage: https://github.com/Shopify/bootsnap
151
152
  licenses:
@@ -159,12 +160,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
160
  requirements:
160
161
  - - ">="
161
162
  - !ruby/object:Gem::Version
162
- version: 2.3.0
163
+ version: 2.0.0
163
164
  required_rubygems_version: !ruby/object:Gem::Requirement
164
165
  requirements:
165
- - - ">="
166
+ - - ">"
166
167
  - !ruby/object:Gem::Version
167
- version: '0'
168
+ version: 1.3.1
168
169
  requirements: []
169
170
  rubyforge_project:
170
171
  rubygems_version: 2.6.10