bootsnap 1.1.6.beta3 → 1.1.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/ext/bootsnap/bootsnap.c +37 -22
- data/lib/bootsnap/load_path_cache/store.rb +1 -1
- data/lib/bootsnap/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2750702dbd4dbefceab7f91bf8ebe6ad477b4646
|
4
|
+
data.tar.gz: b182a96b6addea307c37623196d71d7d4f133bb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a48aab6bd53e30c06b9209b580724386584c3125669a787d43aeb3a656ded4fac42850ab3c5e3bf22d1efa6b0f6fec94498af20b0f4c613d817290e4440f160
|
7
|
+
data.tar.gz: b61b313dc2cf9da4aa524ce8f985b6016532237f168f5eda7d89047dc9493f97a03eecdede3c484295264c9eaec6292740ad9fa53dfa7f0d89c3188630530b99
|
data/CHANGELOG.md
CHANGED
data/ext/bootsnap/bootsnap.c
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
/*
|
33
33
|
* An instance of this key is written as the first 64 bytes of each cache file.
|
34
34
|
* The mtime and size members track whether the file contents have changed, and
|
35
|
-
* the version,
|
35
|
+
* the version, ruby_platform, compile_option, and ruby_revision members track
|
36
36
|
* changes to the environment that could invalidate compile results without
|
37
37
|
* file contents having changed. The data_size member is not truly part of the
|
38
38
|
* "key". Really, this could be called a "header" with the first six members
|
@@ -45,7 +45,7 @@
|
|
45
45
|
*/
|
46
46
|
struct bs_cache_key {
|
47
47
|
uint32_t version;
|
48
|
-
uint32_t
|
48
|
+
uint32_t ruby_platform;
|
49
49
|
uint32_t compile_option;
|
50
50
|
uint32_t ruby_revision;
|
51
51
|
uint64_t size;
|
@@ -67,9 +67,9 @@ STATIC_ASSERT(sizeof(struct bs_cache_key) == KEY_SIZE);
|
|
67
67
|
/* Effectively a schema version. Bumping invalidates all previous caches */
|
68
68
|
static const uint32_t current_version = 2;
|
69
69
|
|
70
|
-
/*
|
71
|
-
*
|
72
|
-
static uint32_t
|
70
|
+
/* hash of e.g. "x86_64-darwin17", invalidating when ruby is recompiled on a
|
71
|
+
* new OS ABI, etc. */
|
72
|
+
static uint32_t current_ruby_platform;
|
73
73
|
/* Invalidates cache when switching ruby versions */
|
74
74
|
static uint32_t current_ruby_revision;
|
75
75
|
/* Invalidates cache when RubyVM::InstructionSequence.compile_option changes */
|
@@ -95,7 +95,7 @@ static VALUE bs_fetch(char * path, VALUE path_v, char * cache_path, VALUE handle
|
|
95
95
|
static int open_current_file(char * path, struct bs_cache_key * key, char ** errno_provenance);
|
96
96
|
static int fetch_cached_data(int fd, ssize_t data_size, VALUE handler, VALUE * output_data, int * exception_tag, char ** errno_provenance);
|
97
97
|
static VALUE prot_exception_for_errno(VALUE err);
|
98
|
-
static uint32_t
|
98
|
+
static uint32_t get_ruby_platform(void);
|
99
99
|
|
100
100
|
/*
|
101
101
|
* Helper functions to call ruby methods on handler object without crashing on
|
@@ -136,7 +136,7 @@ Init_bootsnap(void)
|
|
136
136
|
rb_eBootsnap_CompileCache_Uncompilable = rb_define_class_under(rb_mBootsnap_CompileCache, "Uncompilable", rb_eStandardError);
|
137
137
|
|
138
138
|
current_ruby_revision = FIX2INT(rb_const_get(rb_cObject, rb_intern("RUBY_REVISION")));
|
139
|
-
|
139
|
+
current_ruby_platform = get_ruby_platform();
|
140
140
|
|
141
141
|
uncompilable = rb_intern("__bootsnap_uncompilable__");
|
142
142
|
|
@@ -173,10 +173,9 @@ bs_compile_option_crc32_set(VALUE self, VALUE crc32_v)
|
|
173
173
|
* - 32 bits doesn't feel collision-resistant enough; 64 is nice.
|
174
174
|
*/
|
175
175
|
static uint64_t
|
176
|
-
|
176
|
+
fnv1a_64_iter(uint64_t h, const char *str)
|
177
177
|
{
|
178
178
|
unsigned char *s = (unsigned char *)str;
|
179
|
-
uint64_t h = (uint64_t)0xcbf29ce484222325ULL;
|
180
179
|
|
181
180
|
while (*s) {
|
182
181
|
h ^= (uint64_t)*s++;
|
@@ -186,26 +185,42 @@ fnv1a_64(const char *str)
|
|
186
185
|
return h;
|
187
186
|
}
|
188
187
|
|
188
|
+
static uint64_t
|
189
|
+
fnv1a_64(const char *str)
|
190
|
+
{
|
191
|
+
uint64_t h = (uint64_t)0xcbf29ce484222325ULL;
|
192
|
+
return fnv1a_64_iter(h, str);
|
193
|
+
}
|
194
|
+
|
189
195
|
/*
|
190
|
-
*
|
191
|
-
*
|
196
|
+
* When ruby's version doesn't change, but it's recompiled on a different OS
|
197
|
+
* (or OS version), we need to invalidate the cache.
|
198
|
+
*
|
199
|
+
* We actually factor in some extra information here, to be extra confident
|
200
|
+
* that we don't try to re-use caches that will not be compatible, by factoring
|
201
|
+
* in utsname.version.
|
192
202
|
*/
|
193
203
|
static uint32_t
|
194
|
-
|
204
|
+
get_ruby_platform(void)
|
195
205
|
{
|
196
|
-
#ifdef _WIN32
|
197
|
-
return (uint32_t)GetVersion();
|
198
|
-
#else
|
199
206
|
uint64_t hash;
|
200
|
-
|
207
|
+
VALUE ruby_platform;
|
208
|
+
|
209
|
+
ruby_platform = rb_const_get(rb_cObject, rb_intern("RUBY_PLATFORM"));
|
210
|
+
hash = fnv1a_64(RSTRING_PTR(ruby_platform));
|
201
211
|
|
202
|
-
|
203
|
-
|
212
|
+
#ifdef _WIN32
|
213
|
+
return (uint32_t)(hash >> 32) ^ (uint32_t)GetVersion();
|
214
|
+
#else
|
215
|
+
struct utsname utsname;
|
204
216
|
|
205
|
-
|
217
|
+
/* Not worth crashing if this fails; lose extra cache invalidation potential */
|
218
|
+
if (uname(&utsname) >= 0) {
|
219
|
+
hash = fnv1a_64_iter(hash, utsname.version);
|
220
|
+
}
|
206
221
|
|
207
222
|
return (uint32_t)(hash >> 32);
|
208
|
-
|
223
|
+
#endif
|
209
224
|
}
|
210
225
|
|
211
226
|
/*
|
@@ -239,7 +254,7 @@ cache_key_equal(struct bs_cache_key * k1, struct bs_cache_key * k2)
|
|
239
254
|
{
|
240
255
|
return (
|
241
256
|
k1->version == k2->version &&
|
242
|
-
k1->
|
257
|
+
k1->ruby_platform == k2->ruby_platform &&
|
243
258
|
k1->compile_option == k2->compile_option &&
|
244
259
|
k1->ruby_revision == k2->ruby_revision &&
|
245
260
|
k1->size == k2->size &&
|
@@ -300,7 +315,7 @@ open_current_file(char * path, struct bs_cache_key * key, char ** errno_provenan
|
|
300
315
|
}
|
301
316
|
|
302
317
|
key->version = current_version;
|
303
|
-
key->
|
318
|
+
key->ruby_platform = current_ruby_platform;
|
304
319
|
key->compile_option = current_compile_option_crc32;
|
305
320
|
key->ruby_revision = current_ruby_revision;
|
306
321
|
key->size = (uint64_t)statbuf.st_size;
|
@@ -69,7 +69,7 @@ module Bootsnap
|
|
69
69
|
def dump_data
|
70
70
|
# Change contents atomically so other processes can't get invalid
|
71
71
|
# caches if they read at an inopportune time.
|
72
|
-
tmp = "#{@store_path}.#{(rand * 100000).to_i}.tmp"
|
72
|
+
tmp = "#{@store_path}.#{Process.pid}.#{(rand * 100000).to_i}.tmp"
|
73
73
|
FileUtils.mkpath(File.dirname(tmp))
|
74
74
|
File.binwrite(tmp, MessagePack.dump(@data))
|
75
75
|
FileUtils.mv(tmp, @store_path)
|
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: 1.1.6
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Burke Libbey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -151,9 +151,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
151
|
version: 2.0.0
|
152
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
153
|
requirements:
|
154
|
-
- - "
|
154
|
+
- - ">="
|
155
155
|
- !ruby/object:Gem::Version
|
156
|
-
version:
|
156
|
+
version: '0'
|
157
157
|
requirements: []
|
158
158
|
rubyforge_project:
|
159
159
|
rubygems_version: 2.6.14
|