bootsnap 0.2.8 → 0.2.9
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 +4 -4
- data/README.md +36 -30
- data/lib/bootsnap/load_path_cache/cache.rb +20 -5
- data/lib/bootsnap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe31f9a445fa33edd58c5f58e0f661c0e08d2004
|
4
|
+
data.tar.gz: e01345ff505baf0ce9aa6a104325a93092d0ab53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c319a87aa7d1db72c3535e0af539cd8629852238b4b88bcc1b4a7cf57ea978707aa82b879730815e293c5944b4c40d8b2531a8639780491853c58b66de01191e
|
7
|
+
data.tar.gz: d2d6042b09014425a6d4feb3d1abe28c1a1eaeddd1c29fff8752ba907322349129d065c38109b6d460438b667a72b04626165a59cde12f7af509c9043ba254e5
|
data/README.md
CHANGED
@@ -2,7 +2,40 @@
|
|
2
2
|
|
3
3
|
**Beta-quality. See [the last section of this README](#trustworthiness).**
|
4
4
|
|
5
|
-
Bootsnap is a library that plugs into a number of
|
5
|
+
Bootsnap is a library that plugs into a number of Ruby and (optionally) `ActiveSupport` and `YAML`
|
6
|
+
methods to optimize and cache expensive computations. See [the How Does This Work section](#how-does-this-work) for more information.
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
Add `bootsnap` to your `Gemfile`:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'bootsnap'
|
14
|
+
```
|
15
|
+
|
16
|
+
Next, add this to your boot setup immediately after `require 'bundler/setup'` (i.e. as early as
|
17
|
+
possible: the sooner this is loaded, the sooner it can start optimizing things)
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
require 'bootsnap'
|
21
|
+
Bootsnap.setup(
|
22
|
+
cache_dir: 'tmp/cache', # Path to your cache
|
23
|
+
development_mode: ENV['MY_ENV'] == 'development',
|
24
|
+
load_path_cache: true, # Should we optimize the LOAD_PATH with a cache?
|
25
|
+
autoload_paths_cache: true, # Should we optimize ActiveSupport autoloads with cache?
|
26
|
+
disable_trace: false, # Sets `RubyVM::InstructionSequence.compile_option = { trace_instruction: false }`
|
27
|
+
compile_cache_iseq: true, # Should compile Ruby code into ISeq cache?
|
28
|
+
compile_cache_yaml: true # Should compile YAML into a cache?
|
29
|
+
)
|
30
|
+
```
|
31
|
+
|
32
|
+
**Protip:** You can replace `require 'bootsnap'` with `BootLib::Require.from_gem('bootsnap',
|
33
|
+
'bootsnap')` using [this trick](https://github.com/Shopify/bootsnap/wiki/Bootlib::Require). This
|
34
|
+
will help optimize boot time further if you have an extremely large `$LOAD_PATH`.
|
35
|
+
|
36
|
+
## How does this work?
|
37
|
+
|
38
|
+
Bootsnap is a library that plugs into a number of Ruby and (optionally) `ActiveSupport` and `YAML`
|
6
39
|
methods. These methods are modified to cache results of expensive computations, and can be grouped
|
7
40
|
into two broad categories:
|
8
41
|
|
@@ -69,7 +102,8 @@ In addition to the [`Bootsnap::LoadPathCache::Cache`
|
|
69
102
|
source](https://github.com/Shopify/bootsnap/blob/master/lib/bootsnap/load_path_cache/cache.rb),
|
70
103
|
this diagram may help clarify how entry resolution works:
|
71
104
|
|
72
|
-

|
106
|
+
|
73
107
|
|
74
108
|
It's also important to note how expensive `LoadError`s can be. If ruby invokes
|
75
109
|
`require 'something'`, but that file isn't on `$LOAD_PATH`, it takes `2 *
|
@@ -207,34 +241,6 @@ open /c/nope.bundle -> -1
|
|
207
241
|
# (nothing!)
|
208
242
|
```
|
209
243
|
|
210
|
-
## Usage
|
211
|
-
|
212
|
-
Add `bootsnap` to your `Gemfile`:
|
213
|
-
|
214
|
-
```ruby
|
215
|
-
gem 'bootsnap'
|
216
|
-
```
|
217
|
-
|
218
|
-
Next, add this to your boot setup immediately after `require 'bundler/setup'` (i.e. as early as
|
219
|
-
possible: the sooner this is loaded, the sooner it can start optimizing things)
|
220
|
-
|
221
|
-
```ruby
|
222
|
-
require 'bootsnap'
|
223
|
-
Bootsnap.setup(
|
224
|
-
cache_dir: 'tmp/cache', # Path to your cache
|
225
|
-
development_mode: ENV['MY_ENV'] == 'development',
|
226
|
-
load_path_cache: true, # Should we optimize the LOAD_PATH with a cache?
|
227
|
-
autoload_paths_cache: true, # Should we optimize ActiveSupport autoloads with cache?
|
228
|
-
disable_trace: false, # Sets `RubyVM::InstructionSequence.compile_option = { trace_instruction: false }`
|
229
|
-
compile_cache_iseq: true, # Should compile Ruby code into ISeq cache?
|
230
|
-
compile_cache_yaml: true # Should compile YAML into a cache?
|
231
|
-
)
|
232
|
-
```
|
233
|
-
|
234
|
-
**Protip:** You can replace `require 'bootsnap'` with `BootLib::Require.from_gem('bootsnap',
|
235
|
-
'bootsnap')` using [this trick](https://github.com/Shopify/bootsnap/wiki/Bootlib::Require). This
|
236
|
-
will help optimize boot time further if you have an extremely large `$LOAD_PATH`.
|
237
|
-
|
238
244
|
## Trustworthiness
|
239
245
|
|
240
246
|
We use the `*_path_cache` features in production and haven't experienced any issues in a long time.
|
@@ -22,11 +22,26 @@ module Bootsnap
|
|
22
22
|
@mutex.synchronize { @dirs[dir] }
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
'
|
28
|
-
|
29
|
-
|
25
|
+
# { 'enumerator' => nil, 'enumerator.so' => nil, ... }
|
26
|
+
BUILTIN_FEATURES = $LOADED_FEATURES.reduce({}) do |acc, feat|
|
27
|
+
# Builtin features are of the form 'enumerator.so'.
|
28
|
+
# All others include paths.
|
29
|
+
next acc unless feat.size < 20 && !feat.include?('/')
|
30
|
+
|
31
|
+
base = File.basename(feat, '.*') # enumerator.so -> enumerator
|
32
|
+
ext = File.extname(feat) # .so
|
33
|
+
|
34
|
+
acc[feat] = nil # enumerator.so
|
35
|
+
acc[base] = nil # enumerator
|
36
|
+
|
37
|
+
if [DOT_SO, *DL_EXTENSIONS].include?(ext)
|
38
|
+
DL_EXTENSIONS.each do |ext|
|
39
|
+
acc["#{base}#{ext}"] = nil # enumerator.bundle
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
acc
|
44
|
+
end.freeze
|
30
45
|
|
31
46
|
# Try to resolve this feature to an absolute path without traversing the
|
32
47
|
# loadpath.
|
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: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Burke Libbey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|