bootsnap 1.4.5 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +227 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +57 -20
  5. data/exe/bootsnap +5 -0
  6. data/ext/bootsnap/bootsnap.c +301 -155
  7. data/ext/bootsnap/extconf.rb +22 -14
  8. data/lib/bootsnap/bundler.rb +2 -0
  9. data/lib/bootsnap/cli/worker_pool.rb +136 -0
  10. data/lib/bootsnap/cli.rb +281 -0
  11. data/lib/bootsnap/compile_cache/iseq.rb +64 -19
  12. data/lib/bootsnap/compile_cache/json.rb +93 -0
  13. data/lib/bootsnap/compile_cache/yaml.rb +333 -42
  14. data/lib/bootsnap/compile_cache.rb +26 -8
  15. data/lib/bootsnap/explicit_require.rb +5 -3
  16. data/lib/bootsnap/load_path_cache/cache.rb +65 -37
  17. data/lib/bootsnap/load_path_cache/change_observer.rb +19 -3
  18. data/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb +28 -83
  19. data/lib/bootsnap/load_path_cache/core_ext/loaded_features.rb +2 -0
  20. data/lib/bootsnap/load_path_cache/loaded_features_index.rb +63 -29
  21. data/lib/bootsnap/load_path_cache/path.rb +42 -19
  22. data/lib/bootsnap/load_path_cache/path_scanner.rb +60 -29
  23. data/lib/bootsnap/load_path_cache/store.rb +64 -23
  24. data/lib/bootsnap/load_path_cache.rb +31 -38
  25. data/lib/bootsnap/setup.rb +3 -36
  26. data/lib/bootsnap/version.rb +3 -1
  27. data/lib/bootsnap.rb +127 -36
  28. metadata +15 -99
  29. data/.github/CODEOWNERS +0 -2
  30. data/.github/probots.yml +0 -2
  31. data/.gitignore +0 -17
  32. data/.rubocop.yml +0 -20
  33. data/.travis.yml +0 -21
  34. data/CODE_OF_CONDUCT.md +0 -74
  35. data/CONTRIBUTING.md +0 -21
  36. data/Gemfile +0 -8
  37. data/README.jp.md +0 -231
  38. data/Rakefile +0 -12
  39. data/bin/ci +0 -10
  40. data/bin/console +0 -14
  41. data/bin/setup +0 -8
  42. data/bin/test-minimal-support +0 -7
  43. data/bin/testunit +0 -8
  44. data/bootsnap.gemspec +0 -45
  45. data/dev.yml +0 -10
  46. data/lib/bootsnap/load_path_cache/core_ext/active_support.rb +0 -106
  47. data/lib/bootsnap/load_path_cache/realpath_cache.rb +0 -32
  48. data/shipit.rubygems.yml +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be54a60d54f32f824d5c2fdccf189cdcb5409d1848c55f6e654fe44ace1d3f21
4
- data.tar.gz: c6239c30984a936b76e218c2b1292a7e72d817d3e4847a6c58f0121c1e3068dc
3
+ metadata.gz: 1bf1eca00971c561ca1e15941903dcf193ec8fc84c68736177a3aa72558c536b
4
+ data.tar.gz: bcd5596d1b4b00905af82cf25693fb72e71897685e024b27311353eef6f588bf
5
5
  SHA512:
6
- metadata.gz: c251990457406cd51726eec8d62e0e1028bbeade6e24f266cb743d6f00f53650841beed9ee8e1795c78febd18ea234691125920c16aa5a95031718a28619bb31
7
- data.tar.gz: 554a885bf2264f088618c41864fb84069d0664b35af0ae4b619c8fbb1cf285c80fad564d36845161f8044c35c6b53a33e66f27eb75c6715f25869af2795c97f6
6
+ metadata.gz: 0d3e37e56d994647ac88a1c9b83f087f137d32acfc09bfba1e71a85ce254697b1dcf6c9e1c90b5c71728ce0f3c0a63ee86680455a8f95003d237671435042859
7
+ data.tar.gz: 270bf8fc609981d25441c9c4bd975348130177564f2e1a0744f18720d7f59cda3c3da24bea0c07f2498a185308647b05715e1b1dd5a6045e653600ab2f5907a1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,230 @@
1
+ # Unreleased
2
+
3
+ # 1.16.0
4
+
5
+ * Use `RbConfig::CONFIG["rubylibdir"]` instead of `RbConfig::CONFIG["libdir"]` to check for stdlib files. See #431.
6
+ * Fix the cached version of `YAML.load_file` being slightly more permissive than the default `Psych` one. See #434.
7
+ `Date` and `Time` values are now properly rejected, as well as aliases.
8
+ If this causes a regression in your application, it is recommended to load *trusted* YAML files with `YAML.unsafe_load_file`.
9
+
10
+ # 1.15.0
11
+
12
+ * Add a readonly mode, for environments in which the updated cache wouldn't be persisted. See #428 and #423.
13
+
14
+ # 1.14.0
15
+
16
+ * Require Ruby 2.6.
17
+ * Add a way to skip directories during load path scanning.
18
+ If you have large non-ruby directories in the middle of your load path, it can severely slow down scanning.
19
+ Typically this is a problem with `node_modules`. See #277.
20
+ * Fix `Bootsnap.unload_cache!`, it simply wouldn't work at all becaue of a merge mistake. See #421.
21
+
22
+ # 1.13.0
23
+
24
+ * Stop decorating `Kernel.load`. This used to be very useful in development because the Rails "classic" autoloader
25
+ was using `Kernel.load` in dev and `Kernel.require` in production. But Zeitwerk is now the default, and it doesn't
26
+ use `Kernel.load` at all.
27
+
28
+ People still using the classic autoloader might want to stick to `bootsnap 1.12`.
29
+
30
+ * Add `Bootsnap.unload_cache!`. Applications can call it at the end of their boot sequence when they know
31
+ no more code will be loaded to reclaim a bit of memory.
32
+
33
+ # 1.12.0
34
+
35
+ * `bootsnap precompile` CLI will now also precompile `Rakefile` and `.rake` files.
36
+
37
+ * Stop decorating `Module#autoload` as it was only useful for supporting Ruby 2.2 and older.
38
+
39
+ * Remove `uname` and other patform specific version from the cache keys. `RUBY_PLATFORM + RUBY_REVISION` should be
40
+ enough to ensure bytecode compatibility. This should improve caching for alpine based setups. See #409.
41
+
42
+ # 1.11.1
43
+
44
+ * Fix the `can't modify frozen Hash` error on load path cache mutation. See #411.
45
+
46
+ # 1.11.0
47
+
48
+ * Drop dependency on `fileutils`.
49
+
50
+ * Better respect `Kernel#require` duck typing. While it almost never comes up in practice, `Kernel#require`
51
+ follow a fairly intricate duck-typing protocol on its argument implemented as `rb_get_path(VALUE)` in MRI.
52
+ So when applicable we bind `rb_get_path` and use it for improved compatibility. See #396 and #406.
53
+
54
+ * Get rid of the `Kernel.require_relative` decorator by resolving `$LOAD_PATH` members to their real path.
55
+ This way we handle symlinks in `$LOAD_PATH` much more efficiently. See #402 for the detailed explanation.
56
+
57
+ * Drop support for Ruby 2.3 (to allow getting rid of the `Kernel.require_relative` decorator).
58
+
59
+ # 1.10.3
60
+
61
+ * Fix Regexp and Date type support in YAML compile cache. (#400)
62
+
63
+ * Improve the YAML compile cache to support `UTF-8` symbols. (#398, #399)
64
+ [The default `MessagePack` symbol serializer assumes all symbols are ASCII](https://github.com/msgpack/msgpack-ruby/pull/211),
65
+ because of this, non-ASCII compatible symbol would be restored with `ASCII_8BIT` encoding (AKA `BINARY`).
66
+ Bootsnap now properly cache them in `UTF-8`.
67
+
68
+ Note that the above only apply for actual YAML symbols (e..g `--- :foo`).
69
+ The issue is still present for string keys parsed with `YAML.load_file(..., symbolize_names: true)`, that is a bug
70
+ in `msgpack` that will hopefully be solved soon, see: https://github.com/msgpack/msgpack-ruby/pull/246
71
+
72
+ * Entirely disable the YAML compile cache if `Encoding.default_internal` is set to an encoding not supported by `msgpack`. (#398)
73
+ `Psych` coerce strings to `Encoding.default_internal`, but `MessagePack` doesn't. So in this scenario we can't provide
74
+ YAML caching at all without returning the strings in the wrong encoding.
75
+ This never came up in practice but might as well be safe.
76
+
77
+ # 1.10.2
78
+
79
+ * Reduce the `Kernel.require` extra stack frames some more. Now bootsnap should only add one extra frame per `require` call.
80
+
81
+ * Better check `freeze` option support in JSON compile cache.
82
+ Previously `JSON.load_file(..., freeze: true)` would be cached even when the msgpack version is missing support for it.
83
+
84
+ # 1.10.1
85
+
86
+ * Fix `Kernel#autoload`'s fallback path always being executed.
87
+
88
+ * Consider `unlink` failing with `ENOENT` as a success.
89
+
90
+ # 1.10.0
91
+
92
+ * Delay requiring `FileUtils`. (#285)
93
+ `FileUtils` can be installed as a gem, so it's best to wait for bundler to have setup the load path before requiring it.
94
+
95
+ * Improve support of Psych 4. (#392)
96
+ Since `1.8.0`, `YAML.load_file` was no longer cached when Psych 4 was used. This is because `load_file` loads
97
+ in safe mode by default, so the Bootsnap cache could defeat that safety.
98
+ Now when precompiling YAML files, Bootsnap first try to parse them in safe mode, and if it can't fallback to unsafe mode,
99
+ and the cache contains a flag that records whether it was generated in safe mode or not.
100
+ `YAML.unsafe_load_file` will use safe caches just fine, but `YAML.load_file` will fallback to uncached YAML parsing
101
+ if the cache was generated using unsafe parsing.
102
+
103
+ * Minimize the Kernel.require extra stack frames. (#393)
104
+ This should reduce the noise generated by bootsnap on `LoadError`.
105
+
106
+ # 1.9.4
107
+
108
+ * Ignore absolute paths in the loaded feature index. (#385)
109
+ This fixes a compatibility issue with Zeitwerk when Zeitwerk is loaded before bootsnap. It also should
110
+ reduce the memory usage and improve load performance of Zeitwerk managed files.
111
+
112
+ * Automatically invalidate the load path cache whenever the Ruby version change. (#387)
113
+ This is to avoid issues in case the same installation path is re-used for subsequent ruby patch releases.
114
+
115
+ # 1.9.3
116
+
117
+ * Only disable the compile cache for source files impacted by [Ruby 3.0.3 [Bug 18250]](https://bugs.ruby-lang.org/issues/18250).
118
+ This should keep the performance loss to a minimum.
119
+
120
+ # 1.9.2
121
+
122
+ * Disable compile cache if [Ruby 3.0.3's ISeq cache bug](https://bugs.ruby-lang.org/issues/18250) is detected.
123
+ AKA `iseq.rb:13 to_binary: wrong argument type false (expected Symbol)`
124
+ * Fix `Kernel.load` behavior: before `load 'a'` would load `a.rb` (and other tried extensions) and wouldn't load `a` unless `development_mode: true`, now only `a` would be loaded and files with extensions wouldn't be.
125
+
126
+ # 1.9.1
127
+
128
+ * Removed a forgotten debug statement in JSON precompilation.
129
+
130
+ # 1.9.0
131
+
132
+ * Added a compilation cache for `JSON.load_file`. (#370)
133
+
134
+ # 1.8.1
135
+
136
+ * Fixed support for older Psych. (#369)
137
+
138
+ # 1.8.0
139
+
140
+ * Improve support for Psych 4. (#368)
141
+
142
+ # 1.7.7
143
+
144
+ * Fix `require_relative` in evaled code on latest ruby 3.1.0-dev. (#366)
145
+
146
+ # 1.7.6
147
+
148
+ * Fix reliance on `set` to be required.
149
+ * Fix `Encoding::UndefinedConversionError` error for Rails applications when precompiling cache. (#364)
150
+
151
+ # 1.7.5
152
+
153
+ * Handle a regression of Ruby 2.7.3 causing Bootsnap to call the deprecated `untaint` method. (#360)
154
+ * Gracefully handle read-only file system as well as other errors preventing to persist the load path cache. (#358)
155
+
156
+ # 1.7.4
157
+
158
+ * Stop raising errors when encountering various file system errors. The cache is now best effort,
159
+ if somehow it can't be saved, bootsnap will gracefully fallback to the original operation (e.g. `Kernel.require`).
160
+ (#353, #177, #262)
161
+
162
+ # 1.7.3
163
+
164
+ * Disable YAML precompilation when encountering YAML tags. (#351)
165
+
166
+ # 1.7.2
167
+
168
+ * Fix compatibility with msgpack < 1. (#349)
169
+
170
+ # 1.7.1
171
+
172
+ * Warn Ruby 2.5 users if they turn ISeq caching on. (#327, #244)
173
+ * Disable ISeq caching for the whole 2.5.x series again.
174
+ * Better handle hashing of Ruby strings. (#318)
175
+
176
+ # 1.7.0
177
+
178
+ * Fix detection of YAML files in gems.
179
+ * Adds an instrumentation API to monitor cache misses.
180
+ * Allow to control the behavior of `require 'bootsnap/setup'` using environment variables.
181
+ * Deprecate the `disable_trace` option.
182
+ * Deprecate the `ActiveSupport::Dependencies` (AKA Classic autoloader) integration. (#344)
183
+
184
+ # 1.6.0
185
+
186
+ * Fix a Ruby 2.7/3.0 issue with `YAML.load_file` keyword arguments. (#342)
187
+ * `bootsnap precompile` CLI use multiple processes to complete faster. (#341)
188
+ * `bootsnap precompile` CLI also precompile YAML files. (#340)
189
+ * Changed the load path cache directory from `$BOOTSNAP_CACHE_DIR/bootsnap-load-path-cache` to `$BOOTSNAP_CACHE_DIR/bootsnap/load-path-cache` for ease of use. (#334)
190
+ * Changed the compile cache directory from `$BOOTSNAP_CACHE_DIR/bootsnap-compile-cache` to `$BOOTSNAP_CACHE_DIR/bootsnap/compile-cache` for ease of use. (#334)
191
+
192
+ # 1.5.1
193
+
194
+ * Workaround a Ruby bug in InstructionSequence.compile_file. (#332)
195
+
196
+ # 1.5.0
197
+
198
+ * Add a command line to statically precompile the ISeq cache. (#326)
199
+
200
+ # 1.4.9
201
+
202
+ * [Windows support](https://github.com/Shopify/bootsnap/pull/319)
203
+ * [Fix potential crash](https://github.com/Shopify/bootsnap/pull/322)
204
+
205
+ # 1.4.8
206
+
207
+ * [Prevent FallbackScan from polluting exception cause](https://github.com/Shopify/bootsnap/pull/314)
208
+
209
+ # 1.4.7
210
+
211
+ * Various performance enhancements
212
+ * Fix race condition in heavy concurrent load scenarios that would cause bootsnap to raise
213
+
214
+ # 1.4.6
215
+
216
+ * Fix bug that was erroneously considering that files containing `.` in the names were being
217
+ required if a different file with the same name was already being required
218
+
219
+ Example:
220
+
221
+ require 'foo'
222
+ require 'foo.en'
223
+
224
+ Before bootsnap was considering `foo.en` to be the same file as `foo`
225
+
226
+ * Use glibc as part of the ruby_platform cache key
227
+
1
228
  # 1.4.5
2
229
 
3
230
  * MRI 2.7 support
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017 Shopify, Inc.
3
+ Copyright (c) 2017-present Shopify, Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Bootsnap [![Build Status](https://travis-ci.org/Shopify/bootsnap.svg?branch=master)](https://travis-ci.org/Shopify/bootsnap)
1
+ # Bootsnap [![Actions Status](https://github.com/Shopify/bootsnap/workflows/ci/badge.svg)](https://github.com/Shopify/bootsnap/actions)
2
2
 
3
- Bootsnap is a library that plugs into Ruby, with optional support for `ActiveSupport` and `YAML`,
3
+ Bootsnap is a library that plugs into Ruby, with optional support for `YAML`,
4
4
  to optimize and cache expensive computations. See [How Does This Work](#how-does-this-work).
5
5
 
6
6
  #### Performance
@@ -11,7 +11,7 @@ to optimize and cache expensive computations. See [How Does This Work](#how-does
11
11
  - The core Shopify platform -- a rather large monolithic application -- boots about 75% faster,
12
12
  dropping from around 25s to 6.5s.
13
13
  * In Shopify core (a large app), about 25% of this gain can be attributed to `compile_cache_*`
14
- features; 75% to path caching, and ~1% to `disable_trace`. This is fairly representative.
14
+ features; 75% to path caching. This is fairly representative.
15
15
 
16
16
  ## Usage
17
17
 
@@ -29,7 +29,8 @@ If you are using Rails, add this to `config/boot.rb` immediately after `require
29
29
  require 'bootsnap/setup'
30
30
  ```
31
31
 
32
- Note that bootsnap writes to `tmp/cache`, and that directory *must* be writable. Rails will fail to
32
+ Note that bootsnap writes to `tmp/cache` (or the path specified by `ENV['BOOTSNAP_CACHE_DIR']`),
33
+ and that directory *must* be writable. Rails will fail to
33
34
  boot if it is not. If this is unacceptable (e.g. you are running in a read-only container and
34
35
  unwilling to mount in a writable tmpdir), you should remove this line or wrap it in a conditional.
35
36
 
@@ -40,7 +41,7 @@ getting progressively slower, this is almost certainly the cause.**
40
41
  It's technically possible to simply specify `gem 'bootsnap', require: 'bootsnap/setup'`, but it's
41
42
  important to load Bootsnap as early as possible to get maximum performance improvement.
42
43
 
43
- You can see how this require works [here](https://github.com/Shopify/bootsnap/blob/master/lib/bootsnap/setup.rb).
44
+ You can see how this require works [here](https://github.com/Shopify/bootsnap/blob/main/lib/bootsnap/setup.rb).
44
45
 
45
46
  If you are not using Rails, or if you are but want more control over things, add this to your
46
47
  application setup immediately after `require 'bundler/setup'` (i.e. as early as possible: the sooner
@@ -51,17 +52,15 @@ require 'bootsnap'
51
52
  env = ENV['RAILS_ENV'] || "development"
52
53
  Bootsnap.setup(
53
54
  cache_dir: 'tmp/cache', # Path to your cache
55
+ ignore_directories: ['node_modules'], # Directory names to skip.
54
56
  development_mode: env == 'development', # Current working environment, e.g. RACK_ENV, RAILS_ENV, etc
55
57
  load_path_cache: true, # Optimize the LOAD_PATH with a cache
56
- autoload_paths_cache: true, # Optimize ActiveSupport autoloads with cache
57
- disable_trace: true, # Set `RubyVM::InstructionSequence.compile_option = { trace_instruction: false }`
58
58
  compile_cache_iseq: true, # Compile Ruby code into ISeq cache, breaks coverage reporting.
59
- compile_cache_yaml: true # Compile YAML into a cache
59
+ compile_cache_yaml: true, # Compile YAML into a cache
60
+ readonly: true, # Use the caches but don't update them on miss or stale entries.
60
61
  )
61
62
  ```
62
63
 
63
- **Note that `disable_trace` will break debuggers and tracing.**
64
-
65
64
  **Protip:** You can replace `require 'bootsnap'` with `BootLib::Require.from_gem('bootsnap',
66
65
  'bootsnap')` using [this trick](https://github.com/Shopify/bootsnap/wiki/Bootlib::Require). This
67
66
  will help optimize boot time further if you have an extremely large `$LOAD_PATH`.
@@ -69,7 +68,21 @@ will help optimize boot time further if you have an extremely large `$LOAD_PATH`
69
68
  Note: Bootsnap and [Spring](https://github.com/rails/spring) are orthogonal tools. While Bootsnap
70
69
  speeds up the loading of individual source files, Spring keeps a copy of a pre-booted Rails process
71
70
  on hand to completely skip parts of the boot process the next time it's needed. The two tools work
72
- well together, and are both included in a newly-generated Rails applications by default.
71
+ well together.
72
+
73
+ ### Environment variables
74
+
75
+ `require 'bootsnap/setup'` behavior can be changed using environment variables:
76
+
77
+ - `BOOTSNAP_CACHE_DIR` allows to define the cache location.
78
+ - `DISABLE_BOOTSNAP` allows to entirely disable bootsnap.
79
+ - `DISABLE_BOOTSNAP_LOAD_PATH_CACHE` allows to disable load path caching.
80
+ - `DISABLE_BOOTSNAP_COMPILE_CACHE` allows to disable ISeq and YAML caches.
81
+ - `BOOTSNAP_READONLY` configure bootsnap to not update the cache on miss or stale entries.
82
+ - `BOOTSNAP_LOG` configure bootsnap to log all caches misses to STDERR.
83
+ - `BOOTSNAP_IGNORE_DIRECTORIES` a comma separated list of directories that shouldn't be scanned.
84
+ Useful when you have large directories of non-ruby files inside `$LOAD_PATH`.
85
+ It defaults to ignore any directory named `node_modules`.
73
86
 
74
87
  ### Environments
75
88
 
@@ -77,6 +90,23 @@ All Bootsnap features are enabled in development, test, production, and all othe
77
90
 
78
91
  If you would like to disable any feature for a certain environment, we suggest changing the configuration to take into account the appropriate ENV var or configuration according to your needs.
79
92
 
93
+ ### Instrumentation
94
+
95
+ Bootsnap cache misses can be monitored though a callback:
96
+
97
+ ```ruby
98
+ Bootsnap.instrumentation = ->(event, path) { puts "#{event} #{path}" }
99
+ ```
100
+
101
+ `event` is either `:miss` or `:stale`. You can also call `Bootsnap.log!` as a shortcut to
102
+ log all events to STDERR.
103
+
104
+ To turn instrumentation back off you can set it to nil:
105
+
106
+ ```ruby
107
+ Bootsnap.instrumentation = nil
108
+ ```
109
+
80
110
  ## How does this work?
81
111
 
82
112
  Bootsnap optimizes methods to cache results of expensive computations, and can be grouped
@@ -84,8 +114,6 @@ into two broad categories:
84
114
 
85
115
  * [Path Pre-Scanning](#path-pre-scanning)
86
116
  * `Kernel#require` and `Kernel#load` are modified to eliminate `$LOAD_PATH` scans.
87
- * `ActiveSupport::Dependencies.{autoloadable_module?,load_missing_constant,depend_on}` are
88
- overridden to eliminate scans of `ActiveSupport::Dependencies.autoload_paths`.
89
117
  * [Compilation caching](#compilation-caching)
90
118
  * `RubyVM::InstructionSequence.load_iseq` is implemented to cache the result of ruby bytecode
91
119
  compilation.
@@ -124,10 +152,6 @@ open y/foo.rb
124
152
  ...
125
153
  ```
126
154
 
127
- Exactly the same strategy is employed for methods that traverse
128
- `ActiveSupport::Dependencies.autoload_paths` if the `autoload_paths_cache` option is given to
129
- `Bootsnap.setup`.
130
-
131
155
  The following diagram flowcharts the overrides that make the `*_path_cache` features work.
132
156
 
133
157
  ![Flowchart explaining
@@ -143,7 +167,7 @@ The only directories considered "stable" are things under the Ruby install prefi
143
167
  "volatile".
144
168
 
145
169
  In addition to the [`Bootsnap::LoadPathCache::Cache`
146
- source](https://github.com/Shopify/bootsnap/blob/master/lib/bootsnap/load_path_cache/cache.rb),
170
+ source](https://github.com/Shopify/bootsnap/blob/main/lib/bootsnap/load_path_cache/cache.rb),
147
171
  this diagram may help clarify how entry resolution works:
148
172
 
149
173
  ![How path searching works](https://cloud.githubusercontent.com/assets/3074765/25388270/670b5652-299b-11e7-87fb-975647f68981.png)
@@ -214,9 +238,9 @@ Bootsnap writes a cache file containing a 64 byte header followed by the cache c
214
238
  is a cache key including several fields:
215
239
 
216
240
  * `version`, hardcoded in bootsnap. Essentially a schema version;
217
- * `os_version`, A hash of the current kernel version (on macOS, BSD) or glibc version (on Linux);
241
+ * `ruby_platform`, A hash of `RUBY_PLATFORM` (e.g. x86_64-linux-gnu) variable.
218
242
  * `compile_option`, which changes with `RubyVM::InstructionSequence.compile_option` does;
219
- * `ruby_revision`, the version of Ruby this was compiled with;
243
+ * `ruby_revision`, A hash of `RUBY_REVISION`, the exact version of Ruby;
220
244
  * `size`, the size of the source file;
221
245
  * `mtime`, the last-modification timestamp of the source file when it was compiled; and
222
246
  * `data_size`, the number of bytes following the header, which we need to read it into a buffer.
@@ -294,6 +318,19 @@ open /c/nope.bundle -> -1
294
318
  # (nothing!)
295
319
  ```
296
320
 
321
+ ## Precompilation
322
+
323
+ In development environments the bootsnap compilation cache is generated on the fly when source files are loaded.
324
+ But in production environments, such as docker images, you might need to precompile the cache.
325
+
326
+ To do so you can use the `bootsnap precompile` command.
327
+
328
+ Example:
329
+
330
+ ```bash
331
+ $ bundle exec bootsnap precompile --gemfile app/ lib/
332
+ ```
333
+
297
334
  ## When not to use Bootsnap
298
335
 
299
336
  *Alternative engines*: Bootsnap is pretty reliant on MRI features, and parts are disabled entirely on alternative ruby
data/exe/bootsnap ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bootsnap/cli"
5
+ exit Bootsnap::CLI.new(ARGV).run