bootsnap 1.11.1 → 1.18.3

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: 1cc142349008790c310bcbc875a437996403242e579f85fb48f46eceecb383ad
4
- data.tar.gz: fa1d21fafa8a4fa4d44ced76d597b773d3321e077dc815ccbcae3fe9dc4e661a
3
+ metadata.gz: 4fa4ab785277ee01a1c8ee75b43f0efb93db42bffcdacc1c8505a65efa03dede
4
+ data.tar.gz: 8aaaca48ae257b563580023c8fa36a59463f4c30f5463c14f6b8b94bf5fe27df
5
5
  SHA512:
6
- metadata.gz: 81445538692ae0dc34b7309c44195fce5c864e508afe6eed4124d3d87bc1bfa07fd2ddb2c602faa2409f1537f8da63b885fd692bdc74e961febdd2a39e6e1919
7
- data.tar.gz: 6389ce3a667c528660976665ce8184fb61d638da6cd4040e7b2d55441679574bdf691e4991294396c19a6e79bbf185ba1cdca848d5ea499a5b8e197dca143a5f
6
+ metadata.gz: 27b48d27d3330c8565952a2fbb979e71013b1e9585bcb3284656192808c304f2874c32a135b14895eec61a7ef038fa71fa111964a56e7aaedc9ff507ef307686
7
+ data.tar.gz: c3d83a0b068f2908a6298c7cd8e1a660f1228a7ddbfb9409cb3f6c174319f3974388ce73756c04062b17b97a37e199a07bccbb0b8dc1c6224998c58c51194b27
data/CHANGELOG.md CHANGED
@@ -1,5 +1,81 @@
1
1
  # Unreleased
2
2
 
3
+ # 1.18.3
4
+
5
+ * Fix the cache corruption issue in the revalidation feature. See #474.
6
+ The cache revalidation feature remains opt-in for now, until it is more battle tested.
7
+
8
+ # 1.18.2
9
+
10
+ * Disable stale cache entries revalidation by default as it seems to cause cache corruption issues. See #471 and #474.
11
+ Will be re-enabled in a future version once the root cause is identified.
12
+ * Fix a potential compilation issue on some systems. See #470.
13
+
14
+ # 1.18.1
15
+
16
+ * Handle `EPERM` errors when opening files with `O_NOATIME`.
17
+
18
+ # 1.18.0
19
+
20
+ * `Bootsnap.instrumentation` now receive `:hit` events.
21
+ * Add `Bootsnap.log_stats!` to print hit rate statistics on process exit. Can also be enabled with `BOOTSNAP_STATS=1`.
22
+ * Revalidate stale cache entries by digesting the source content.
23
+ This should significantly improve performance in environments where `mtime` isn't preserved (e.g. CI systems doing a git clone, etc).
24
+ See #468.
25
+ * Open source files and cache entries with `O_NOATIME` when available to reduce disk accesses. See #469.
26
+ * `bootsnap precompile --gemfile` now look for `.rb` files in the whole gem and not just the `lib/` directory. See #466.
27
+
28
+ # 1.17.1
29
+
30
+ * Fix a compatibility issue with the `prism` library that ships with Ruby 3.3. See #463.
31
+ * Improved the `Kernel#require` decorator to not cause a method redefinition warning. See #461.
32
+
33
+ # 1.17.0
34
+
35
+ * Ensure `$LOAD_PATH.dup` is Ractor shareable to fix an conflict with `did_you_mean`.
36
+ * Allow to ignore directories using absolute paths.
37
+ * Support YAML and JSON CompileCache on TruffleRuby.
38
+ * Support LoadPathCache on TruffleRuby.
39
+
40
+ # 1.16.0
41
+
42
+ * Use `RbConfig::CONFIG["rubylibdir"]` instead of `RbConfig::CONFIG["libdir"]` to check for stdlib files. See #431.
43
+ * Fix the cached version of `YAML.load_file` being slightly more permissive than the default `Psych` one. See #434.
44
+ `Date` and `Time` values are now properly rejected, as well as aliases.
45
+ If this causes a regression in your application, it is recommended to load *trusted* YAML files with `YAML.unsafe_load_file`.
46
+
47
+ # 1.15.0
48
+
49
+ * Add a readonly mode, for environments in which the updated cache wouldn't be persisted. See #428 and #423.
50
+
51
+ # 1.14.0
52
+
53
+ * Require Ruby 2.6.
54
+ * Add a way to skip directories during load path scanning.
55
+ If you have large non-ruby directories in the middle of your load path, it can severely slow down scanning.
56
+ Typically this is a problem with `node_modules`. See #277.
57
+ * Fix `Bootsnap.unload_cache!`, it simply wouldn't work at all because of a merge mistake. See #421.
58
+
59
+ # 1.13.0
60
+
61
+ * Stop decorating `Kernel.load`. This used to be very useful in development because the Rails "classic" autoloader
62
+ was using `Kernel.load` in dev and `Kernel.require` in production. But Zeitwerk is now the default, and it doesn't
63
+ use `Kernel.load` at all.
64
+
65
+ People still using the classic autoloader might want to stick to `bootsnap 1.12`.
66
+
67
+ * Add `Bootsnap.unload_cache!`. Applications can call it at the end of their boot sequence when they know
68
+ no more code will be loaded to reclaim a bit of memory.
69
+
70
+ # 1.12.0
71
+
72
+ * `bootsnap precompile` CLI will now also precompile `Rakefile` and `.rake` files.
73
+
74
+ * Stop decorating `Module#autoload` as it was only useful for supporting Ruby 2.2 and older.
75
+
76
+ * Remove `uname` and other platform specific version from the cache keys. `RUBY_PLATFORM + RUBY_REVISION` should be
77
+ enough to ensure bytecode compatibility. This should improve caching for alpine based setups. See #409.
78
+
3
79
  # 1.11.1
4
80
 
5
81
  * Fix the `can't modify frozen Hash` error on load path cache mutation. See #411.
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
 
@@ -183,9 +192,9 @@ translated ruby source to an internal bytecode format, which is then executed by
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.