bootsnap 1.10.3 → 1.18.6

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
  SHA256:
3
- metadata.gz: 3dfd9cfb2cde26fc31c82206b73f3940b4b46903a3fa73d0f3f1a4c4a90c6984
4
- data.tar.gz: 6dd8acfb2676a2585eb320ed50ba0ddb9f9c847fb415bcda824c7ebff0cce752
3
+ metadata.gz: 962bb65ac06446a7f6a1bace4373f552c46f198cedbf32fa1584a531c7f96f48
4
+ data.tar.gz: fc84432aa3a728562b7a3d0b29d2edf74a2ee39a888129e56882e8c061571a2d
5
5
  SHA512:
6
- metadata.gz: 219a84be718e4ac5681621739b6f9400d77a16dee631bdc286adad87c0ddf99cc581da7281150add34075c08c59832df2a468524656d2f1ac36ac1613be051bb
7
- data.tar.gz: 0e407a034fd081c9e506637e0997d0c2cc0eea312be798f6fd0d573173699f906f1b43a1f3d37ff64ee6efb2f9257228c6c4e7663b7337bfc49d99e5089fccb9
6
+ metadata.gz: 18daeec63113ff6eefc97058720d2e9d1703da5e2cc5d1a7e69db3d3d927a89ac156164138c113bcd44dd1fe4f49e7177b4f552c4839872fa11a6385e7413655
7
+ data.tar.gz: a8b29f7ea54243953887da78816599bec864240650072e53496446146190c9be8f54a2539cd29f4aebcccb0cbcacdad2dfd2ae187e61b6dcad0ea91fe6aeddcc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,111 @@
1
1
  # Unreleased
2
2
 
3
+ * Fix cgroup CPU limits detection in CLI.
4
+
5
+ # 1.18.5
6
+
7
+ * Attempt to detect a QEMU bug that can cause `bootsnap precompile` to hang forever when building ARM64 docker images
8
+ from x86_64 machines. See #495.
9
+ * Improve CLI to detect cgroup CPU limits and avoid spawning too many worker processes.
10
+
11
+ # 1.18.4
12
+
13
+ * Allow using bootsnap without bundler. See #488.
14
+ * Fix startup failure if the cache directory points to a broken symlink.
15
+
16
+ # 1.18.3
17
+
18
+ * Fix the cache corruption issue in the revalidation feature. See #474.
19
+ The cache revalidation feature remains opt-in for now, until it is more battle tested.
20
+
21
+ # 1.18.2
22
+
23
+ * Disable stale cache entries revalidation by default as it seems to cause cache corruption issues. See #471 and #474.
24
+ Will be re-enabled in a future version once the root cause is identified.
25
+ * Fix a potential compilation issue on some systems. See #470.
26
+
27
+ # 1.18.1
28
+
29
+ * Handle `EPERM` errors when opening files with `O_NOATIME`.
30
+
31
+ # 1.18.0
32
+
33
+ * `Bootsnap.instrumentation` now receive `:hit` events.
34
+ * Add `Bootsnap.log_stats!` to print hit rate statistics on process exit. Can also be enabled with `BOOTSNAP_STATS=1`.
35
+ * Revalidate stale cache entries by digesting the source content.
36
+ This should significantly improve performance in environments where `mtime` isn't preserved (e.g. CI systems doing a git clone, etc).
37
+ See #468.
38
+ * Open source files and cache entries with `O_NOATIME` when available to reduce disk accesses. See #469.
39
+ * `bootsnap precompile --gemfile` now look for `.rb` files in the whole gem and not just the `lib/` directory. See #466.
40
+
41
+ # 1.17.1
42
+
43
+ * Fix a compatibility issue with the `prism` library that ships with Ruby 3.3. See #463.
44
+ * Improved the `Kernel#require` decorator to not cause a method redefinition warning. See #461.
45
+
46
+ # 1.17.0
47
+
48
+ * Ensure `$LOAD_PATH.dup` is Ractor shareable to fix a conflict with `did_you_mean`.
49
+ * Allow to ignore directories using absolute paths.
50
+ * Support YAML and JSON CompileCache on TruffleRuby.
51
+ * Support LoadPathCache on TruffleRuby.
52
+
53
+ # 1.16.0
54
+
55
+ * Use `RbConfig::CONFIG["rubylibdir"]` instead of `RbConfig::CONFIG["libdir"]` to check for stdlib files. See #431.
56
+ * Fix the cached version of `YAML.load_file` being slightly more permissive than the default `Psych` one. See #434.
57
+ `Date` and `Time` values are now properly rejected, as well as aliases.
58
+ If this causes a regression in your application, it is recommended to load *trusted* YAML files with `YAML.unsafe_load_file`.
59
+
60
+ # 1.15.0
61
+
62
+ * Add a readonly mode, for environments in which the updated cache wouldn't be persisted. See #428 and #423.
63
+
64
+ # 1.14.0
65
+
66
+ * Require Ruby 2.6.
67
+ * Add a way to skip directories during load path scanning.
68
+ If you have large non-ruby directories in the middle of your load path, it can severely slow down scanning.
69
+ Typically this is a problem with `node_modules`. See #277.
70
+ * Fix `Bootsnap.unload_cache!`, it simply wouldn't work at all because of a merge mistake. See #421.
71
+
72
+ # 1.13.0
73
+
74
+ * Stop decorating `Kernel.load`. This used to be very useful in development because the Rails "classic" autoloader
75
+ was using `Kernel.load` in dev and `Kernel.require` in production. But Zeitwerk is now the default, and it doesn't
76
+ use `Kernel.load` at all.
77
+
78
+ People still using the classic autoloader might want to stick to `bootsnap 1.12`.
79
+
80
+ * Add `Bootsnap.unload_cache!`. Applications can call it at the end of their boot sequence when they know
81
+ no more code will be loaded to reclaim a bit of memory.
82
+
83
+ # 1.12.0
84
+
85
+ * `bootsnap precompile` CLI will now also precompile `Rakefile` and `.rake` files.
86
+
87
+ * Stop decorating `Module#autoload` as it was only useful for supporting Ruby 2.2 and older.
88
+
89
+ * Remove `uname` and other platform specific version from the cache keys. `RUBY_PLATFORM + RUBY_REVISION` should be
90
+ enough to ensure bytecode compatibility. This should improve caching for alpine based setups. See #409.
91
+
92
+ # 1.11.1
93
+
94
+ * Fix the `can't modify frozen Hash` error on load path cache mutation. See #411.
95
+
96
+ # 1.11.0
97
+
98
+ * Drop dependency on `fileutils`.
99
+
100
+ * Better respect `Kernel#require` duck typing. While it almost never comes up in practice, `Kernel#require`
101
+ follow a fairly intricate duck-typing protocol on its argument implemented as `rb_get_path(VALUE)` in MRI.
102
+ So when applicable we bind `rb_get_path` and use it for improved compatibility. See #396 and #406.
103
+
104
+ * Get rid of the `Kernel.require_relative` decorator by resolving `$LOAD_PATH` members to their real path.
105
+ This way we handle symlinks in `$LOAD_PATH` much more efficiently. See #402 for the detailed explanation.
106
+
107
+ * Drop support for Ruby 2.3 (to allow getting rid of the `Kernel.require_relative` decorator).
108
+
3
109
  # 1.10.3
4
110
 
5
111
  * Fix Regexp and Date type support in YAML compile cache. (#400)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
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 `YAML`,
3
+ Bootsnap is a library that plugs into Ruby, with optional support for `YAML` and `JSON`,
4
4
  to optimize and cache expensive computations. See [How Does This Work](#how-does-this-work).
5
5
 
6
6
  #### Performance
@@ -52,10 +52,13 @@ require 'bootsnap'
52
52
  env = ENV['RAILS_ENV'] || "development"
53
53
  Bootsnap.setup(
54
54
  cache_dir: 'tmp/cache', # Path to your cache
55
+ ignore_directories: ['node_modules'], # Directory names to skip.
55
56
  development_mode: env == 'development', # Current working environment, e.g. RACK_ENV, RAILS_ENV, etc
56
57
  load_path_cache: true, # Optimize the LOAD_PATH with a cache
57
58
  compile_cache_iseq: true, # Compile Ruby code into ISeq cache, breaks coverage reporting.
58
- compile_cache_yaml: true # Compile YAML into a cache
59
+ compile_cache_yaml: true, # Compile YAML into a cache
60
+ compile_cache_json: true, # Compile JSON into a cache
61
+ readonly: true, # Use the caches but don't update them on miss or stale entries.
59
62
  )
60
63
  ```
61
64
 
@@ -66,7 +69,7 @@ will help optimize boot time further if you have an extremely large `$LOAD_PATH`
66
69
  Note: Bootsnap and [Spring](https://github.com/rails/spring) are orthogonal tools. While Bootsnap
67
70
  speeds up the loading of individual source files, Spring keeps a copy of a pre-booted Rails process
68
71
  on hand to completely skip parts of the boot process the next time it's needed. The two tools work
69
- well together, and are both included in a newly-generated Rails applications by default.
72
+ well together.
70
73
 
71
74
  ### Environment variables
72
75
 
@@ -76,7 +79,12 @@ well together, and are both included in a newly-generated Rails applications by
76
79
  - `DISABLE_BOOTSNAP` allows to entirely disable bootsnap.
77
80
  - `DISABLE_BOOTSNAP_LOAD_PATH_CACHE` allows to disable load path caching.
78
81
  - `DISABLE_BOOTSNAP_COMPILE_CACHE` allows to disable ISeq and YAML caches.
82
+ - `BOOTSNAP_READONLY` configure bootsnap to not update the cache on miss or stale entries.
79
83
  - `BOOTSNAP_LOG` configure bootsnap to log all caches misses to STDERR.
84
+ - `BOOTSNAP_STATS` log hit rate statistics on exit. Can't be used if `BOOTSNAP_LOG` is enabled.
85
+ - `BOOTSNAP_IGNORE_DIRECTORIES` a comma separated list of directories that shouldn't be scanned.
86
+ Useful when you have large directories of non-ruby files inside `$LOAD_PATH`.
87
+ It defaults to ignore any directory named `node_modules`.
80
88
 
81
89
  ### Environments
82
90
 
@@ -92,8 +100,8 @@ Bootsnap cache misses can be monitored though a callback:
92
100
  Bootsnap.instrumentation = ->(event, path) { puts "#{event} #{path}" }
93
101
  ```
94
102
 
95
- `event` is either `:miss` or `:stale`. You can also call `Bootsnap.log!` as a shortcut to
96
- log all events to STDERR.
103
+ `event` is either `:hit`, `:miss`, `:stale` or `:revalidated`.
104
+ You can also call `Bootsnap.log!` as a shortcut to log all events to STDERR.
97
105
 
98
106
  To turn instrumentation back off you can set it to nil:
99
107
 
@@ -113,6 +121,7 @@ into two broad categories:
113
121
  compilation.
114
122
  * `YAML.load_file` is modified to cache the result of loading a YAML object in MessagePack format
115
123
  (or Marshal, if the message uses types unsupported by MessagePack).
124
+ * `JSON.load_file` is modified to cache the result of loading a JSON object in MessagePack format
116
125
 
117
126
  ### Path Pre-Scanning
118
127
 
@@ -179,13 +188,13 @@ result too, raising a `LoadError` without touching the filesystem at all.
179
188
 
180
189
  Ruby has complex grammar and parsing it is not a particularly cheap operation. Since 1.9, Ruby has
181
190
  translated ruby source to an internal bytecode format, which is then executed by the Ruby VM. Since
182
- 2.3.0, Ruby [exposes an API](https://ruby-doc.org/core-2.3.0/RubyVM/InstructionSequence.html) that
191
+ 2.3.0, Ruby [exposes an API](https://docs.ruby-lang.org/en/master/RubyVM/InstructionSequence.html) that
183
192
  allows caching that bytecode. This allows us to bypass the relatively-expensive compilation step on
184
193
  subsequent loads of the same file.
185
194
 
186
- We also noticed that we spend a lot of time loading YAML documents during our application boot, and
187
- that MessagePack and Marshal are *much* faster at deserialization than YAML, even with a fast
188
- implementation. We use the same strategy of compilation caching for YAML documents, with the
195
+ We also noticed that we spend a lot of time loading YAML and JSON documents during our application boot, and
196
+ that MessagePack and Marshal are *much* faster at deserialization than YAML and JSON, even with a fast
197
+ implementation. We use the same strategy of compilation caching for YAML and JSON documents, with the
189
198
  equivalent of Ruby's "bytecode" format being a MessagePack document (or, in the case of YAML
190
199
  documents with types unsupported by MessagePack, a Marshal stream).
191
200
 
@@ -232,9 +241,9 @@ Bootsnap writes a cache file containing a 64 byte header followed by the cache c
232
241
  is a cache key including several fields:
233
242
 
234
243
  * `version`, hardcoded in bootsnap. Essentially a schema version;
235
- * `ruby_platform`, A hash of `RUBY_PLATFORM` (e.g. x86_64-linux-gnu) variable and glibc version (on Linux) or OS version (`uname -v` on BSD, macOS)
244
+ * `ruby_platform`, A hash of `RUBY_PLATFORM` (e.g. x86_64-linux-gnu) variable.
236
245
  * `compile_option`, which changes with `RubyVM::InstructionSequence.compile_option` does;
237
- * `ruby_revision`, the version of Ruby this was compiled with;
246
+ * `ruby_revision`, A hash of `RUBY_REVISION`, the exact version of Ruby;
238
247
  * `size`, the size of the source file;
239
248
  * `mtime`, the last-modification timestamp of the source file when it was compiled; and
240
249
  * `data_size`, the number of bytes following the header, which we need to read it into a buffer.
@@ -322,7 +331,7 @@ To do so you can use the `bootsnap precompile` command.
322
331
  Example:
323
332
 
324
333
  ```bash
325
- $ bundle exec bootsnap precompile --gemfile app/ lib/
334
+ $ bundle exec bootsnap precompile --gemfile app/ lib/ config/
326
335
  ```
327
336
 
328
337
  ## When not to use Bootsnap