bootsnap 1.1.5 → 1.1.6.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/README.md +5 -20
- data/ext/bootsnap/bootsnap.c +20 -10
- data/lib/bootsnap.rb +1 -0
- data/lib/bootsnap/bundler.rb +12 -0
- data/lib/bootsnap/load_path_cache/core_ext/active_support.rb +4 -0
- data/lib/bootsnap/load_path_cache/path.rb +1 -1
- data/lib/bootsnap/load_path_cache/path_scanner.rb +2 -1
- data/lib/bootsnap/setup.rb +4 -10
- data/lib/bootsnap/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 784acf6d2a96507d9de9157b756638da8b7608a0
|
4
|
+
data.tar.gz: 512ef099f20aaa5a15c06d4da67f2c4f6db066f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd76edbe3f2f62313dbfe86c3d0b4c661cff63c5e735d43992e59be9b08c86d11e1379f54c1dbc6b87b5355e29201f2e9c5431459fb078ed392778065783f52d
|
7
|
+
data.tar.gz: cfab4dfe53c4baffd3e46a939ceb07eff285f4b0a607df521f7f0b20ea9f66284a32eade3732ed12decd10c11c1c561664d32ba4230db8b4ae8d9fb46655f113
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# Bootsnap [![Build Status](https://travis-ci.org/Shopify/bootsnap.svg?branch=master)](https://travis-ci.org/Shopify/bootsnap)
|
2
2
|
|
3
|
-
**Beta-quality. See [the last section of this README](#trustworthiness).**
|
4
|
-
|
5
3
|
Bootsnap is a library that plugs into Ruby, with optional support for `ActiveSupport` and `YAML`,
|
6
4
|
to optimize and cache expensive computations. See [How Does This Work](#how-does-this-work).
|
7
5
|
|
@@ -48,6 +46,11 @@ Bootsnap.setup(
|
|
48
46
|
'bootsnap')` using [this trick](https://github.com/Shopify/bootsnap/wiki/Bootlib::Require). This
|
49
47
|
will help optimize boot time further if you have an extremely large `$LOAD_PATH`.
|
50
48
|
|
49
|
+
Note: Bootsnap and [Spring](https://github.com/rails/spring) are orthogonal tools. While Bootsnap
|
50
|
+
speeds up the loading of individual source files, Spring keeps a copy of a pre-booted Rails process
|
51
|
+
on hand to completely skip parts of the boot process the next time it's needed. The two tools work
|
52
|
+
well together, and are both included in a newly-generated Rails applications by default.
|
53
|
+
|
51
54
|
## How does this work?
|
52
55
|
|
53
56
|
Bootsnap optimizes methods to cache results of expensive computations, and can be grouped
|
@@ -264,21 +267,3 @@ open /c/nope.bundle -> -1
|
|
264
267
|
```
|
265
268
|
# (nothing!)
|
266
269
|
```
|
267
|
-
|
268
|
-
## Trustworthiness
|
269
|
-
|
270
|
-
We use the `*_path_cache` features in production and haven't experienced any issues in a long time.
|
271
|
-
|
272
|
-
The `compile_cache_*` features work well for us in development on macOS. It should work on Linux,
|
273
|
-
and we intend to deploy it in production, but we haven't yet.
|
274
|
-
|
275
|
-
`disable_trace` should be completely safe, but we don't really use it because some people like to
|
276
|
-
use tools that make use of `trace` instructions.
|
277
|
-
|
278
|
-
| feature | where we're using it |
|
279
|
-
|-|-|
|
280
|
-
| `load_path_cache` | everywhere |
|
281
|
-
| `autoload_path_cache` | everywhere |
|
282
|
-
| `disable_trace` | nowhere, but it's safe unless you need tracing |
|
283
|
-
| `compile_cache_iseq` | development, but probably safe to use everywhere |
|
284
|
-
| `compile_cache_yaml` | development, but probably safe to use everywhere |
|
data/ext/bootsnap/bootsnap.c
CHANGED
@@ -513,24 +513,24 @@ bs_read_contents(int fd, size_t size, char ** contents)
|
|
513
513
|
* Bootsnap::CompileCache::Native.fetch.
|
514
514
|
*
|
515
515
|
* There are three "formats" in use here:
|
516
|
-
* 1. "input"
|
516
|
+
* 1. "input" format, which is what we load from the source file;
|
517
517
|
* 2. "storage" format, which we write to the cache;
|
518
518
|
* 3. "output" format, which is what we return.
|
519
519
|
*
|
520
520
|
* E.g., For ISeq compilation:
|
521
|
-
* input:
|
521
|
+
* input: ruby source, as text
|
522
522
|
* storage: binary string (RubyVM::InstructionSequence#to_binary)
|
523
|
-
* output:
|
523
|
+
* output: Instance of RubyVM::InstructionSequence
|
524
524
|
*
|
525
525
|
* And for YAML:
|
526
|
-
* input:
|
526
|
+
* input: yaml as text
|
527
527
|
* storage: MessagePack or Marshal text
|
528
|
-
* output:
|
528
|
+
* output: ruby object, loaded from yaml/messagepack/marshal
|
529
529
|
*
|
530
|
-
*
|
531
|
-
* * storage_to_output(
|
532
|
-
* * input_to_output(
|
533
|
-
* * input_to_storage(
|
530
|
+
* A handler<I,S,O> passed in must support three messages:
|
531
|
+
* * storage_to_output(S) -> O
|
532
|
+
* * input_to_output(I) -> O
|
533
|
+
* * input_to_storage(I) -> S
|
534
534
|
* (input_to_storage may raise Bootsnap::CompileCache::Uncompilable, which
|
535
535
|
* will prevent caching and cause output to be generated with
|
536
536
|
* input_to_output)
|
@@ -655,7 +655,17 @@ invalid_type_storage_data:
|
|
655
655
|
/********************* Handler Wrappers **************************************/
|
656
656
|
/*****************************************************************************
|
657
657
|
* Everything after this point in the file is just wrappers to deal with ruby's
|
658
|
-
* clunky method of handling exceptions from ruby methods invoked from C
|
658
|
+
* clunky method of handling exceptions from ruby methods invoked from C:
|
659
|
+
*
|
660
|
+
* In order to call a ruby method from C, while protecting against crashing in
|
661
|
+
* the event of an exception, we must call the method with rb_protect().
|
662
|
+
*
|
663
|
+
* rb_protect takes a C function and precisely one argument; however, we want
|
664
|
+
* to pass multiple arguments, so we must create structs to wrap them up.
|
665
|
+
*
|
666
|
+
* These functions return an exception_tag, which, if non-zero, indicates an
|
667
|
+
* exception that should be jumped to with rb_jump_tag after cleaning up
|
668
|
+
* allocated resources.
|
659
669
|
*/
|
660
670
|
|
661
671
|
struct s2o_data {
|
data/lib/bootsnap.rb
CHANGED
@@ -45,6 +45,10 @@ module Bootsnap
|
|
45
45
|
# NoMethodError is a NameError, but we only want to handle actual
|
46
46
|
# NameError instances.
|
47
47
|
raise unless e.class == NameError
|
48
|
+
# We can only confidently handle cases when *this* constant fails
|
49
|
+
# to load, not other constants referred to by it.
|
50
|
+
raise unless e.name == const_name
|
51
|
+
# If the constant was actually loaded, something else went wrong?
|
48
52
|
raise if from_mod.const_defined?(const_name)
|
49
53
|
CoreExt::ActiveSupport.without_bootsnap_cache { super }
|
50
54
|
end
|
@@ -99,7 +99,7 @@ module Bootsnap
|
|
99
99
|
@stability ||= begin
|
100
100
|
if Gem.path.detect { |p| expanded_path.start_with?(p.to_s) }
|
101
101
|
STABLE
|
102
|
-
elsif expanded_path.start_with?(Bundler.bundle_path.to_s)
|
102
|
+
elsif Bootsnap.bundler? && expanded_path.start_with?(Bundler.bundle_path.to_s)
|
103
103
|
STABLE
|
104
104
|
elsif expanded_path.start_with?(RUBY_LIBDIR) && !expanded_path.start_with?(RUBY_SITEDIR)
|
105
105
|
STABLE
|
@@ -15,7 +15,8 @@ module Bootsnap
|
|
15
15
|
REQUIRABLES_AND_DIRS = "/{,*/**/}*{#{DOT_RB},#{DL_EXTENSIONS.join(',')},/}"
|
16
16
|
NORMALIZE_NATIVE_EXTENSIONS = !DL_EXTENSIONS.include?(LoadPathCache::DOT_SO)
|
17
17
|
ALTERNATIVE_NATIVE_EXTENSIONS_PATTERN = /\.(o|bundle|dylib)\z/
|
18
|
-
BUNDLE_PATH =
|
18
|
+
BUNDLE_PATH = Bootsnap.bundler? ?
|
19
|
+
(Bundler.bundle_path.cleanpath.to_s << LoadPathCache::SLASH).freeze : ''.freeze
|
19
20
|
|
20
21
|
def self.call(path)
|
21
22
|
path = path.to_s
|
data/lib/bootsnap/setup.rb
CHANGED
@@ -4,16 +4,10 @@ env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || ENV['ENV']
|
|
4
4
|
development_mode = ['', nil, 'development'].include?(env)
|
5
5
|
|
6
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
|
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
|
7
|
+
enable_cc =
|
8
|
+
RUBY_ENGINE == 'ruby' &&
|
9
|
+
RUBY_PLATFORM =~ /darwin|linux|bsd/ &&
|
10
|
+
Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.3.0")
|
17
11
|
|
18
12
|
cache_dir = ENV['BOOTSNAP_CACHE_DIR']
|
19
13
|
unless cache_dir
|
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.1.
|
4
|
+
version: 1.1.6.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Burke Libbey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- ext/bootsnap/bootsnap.h
|
122
122
|
- ext/bootsnap/extconf.rb
|
123
123
|
- lib/bootsnap.rb
|
124
|
+
- lib/bootsnap/bundler.rb
|
124
125
|
- lib/bootsnap/compile_cache.rb
|
125
126
|
- lib/bootsnap/compile_cache/iseq.rb
|
126
127
|
- lib/bootsnap/compile_cache/yaml.rb
|
@@ -150,12 +151,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
151
|
version: 2.0.0
|
151
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
153
|
requirements:
|
153
|
-
- - "
|
154
|
+
- - ">"
|
154
155
|
- !ruby/object:Gem::Version
|
155
|
-
version:
|
156
|
+
version: 1.3.1
|
156
157
|
requirements: []
|
157
158
|
rubyforge_project:
|
158
|
-
rubygems_version: 2.6.
|
159
|
+
rubygems_version: 2.6.14
|
159
160
|
signing_key:
|
160
161
|
specification_version: 4
|
161
162
|
summary: Boot large ruby/rails apps faster
|