|
1 | 1 | # Bootsnap [](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
|
@@ -57,6 +57,7 @@ Bootsnap.setup(
|
57 | 57 | load_path_cache: true, # Optimize the LOAD_PATH with a cache
|
58 | 58 | compile_cache_iseq: true, # Compile Ruby code into ISeq cache, breaks coverage reporting.
|
59 | 59 | compile_cache_yaml: true, # Compile YAML into a cache
|
| 60 | + compile_cache_json: true, # Compile JSON into a cache |
60 | 61 | readonly: true, # Use the caches but don't update them on miss or stale entries.
|
61 | 62 | )
|
62 | 63 | ```
|
@@ -119,6 +120,7 @@ into two broad categories:
|
119 | 120 | compilation.
|
120 | 121 | * `YAML.load_file` is modified to cache the result of loading a YAML object in MessagePack format
|
121 | 122 | (or Marshal, if the message uses types unsupported by MessagePack).
|
| 123 | + * `JSON.load_file` is modified to cache the result of loading a JSON object in MessagePack format |
122 | 124 |
|
123 | 125 | ### Path Pre-Scanning
|
124 | 126 |
|
@@ -189,9 +191,9 @@ translated ruby source to an internal bytecode format, which is then executed by
|
189 | 191 | allows caching that bytecode. This allows us to bypass the relatively-expensive compilation step on
|
190 | 192 | subsequent loads of the same file.
|
191 | 193 |
|
192 |
| -We also noticed that we spend a lot of time loading YAML documents during our application boot, and |
193 |
| -that MessagePack and Marshal are *much* faster at deserialization than YAML, even with a fast |
194 |
| -implementation. We use the same strategy of compilation caching for YAML documents, with the |
| 194 | +We also noticed that we spend a lot of time loading YAML and JSON documents during our application boot, and |
| 195 | +that MessagePack and Marshal are *much* faster at deserialization than YAML and JSON, even with a fast |
| 196 | +implementation. We use the same strategy of compilation caching for YAML and JSON documents, with the |
195 | 197 | equivalent of Ruby's "bytecode" format being a MessagePack document (or, in the case of YAML
|
196 | 198 | documents with types unsupported by MessagePack, a Marshal stream).
|
197 | 199 |
|
|
0 commit comments