bootsnap 1.1.6.beta3 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 003a19644d8dac109753f80603c992ca0ab787fe
4
- data.tar.gz: dbc75695231d5e968f6bf3f29cc3e75ada7c9148
3
+ metadata.gz: 2750702dbd4dbefceab7f91bf8ebe6ad477b4646
4
+ data.tar.gz: b182a96b6addea307c37623196d71d7d4f133bb4
5
5
  SHA512:
6
- metadata.gz: de875383c5e274a5ae044ca4c8b44d53c97cbfebfeb9c9a9f375068d750e2ce00447ca4cf3a5165287b1ddabc22275c7ac9b064cd29eaa56c363ba47588ddbf5
7
- data.tar.gz: d437f735ba246721eaf979dbed81f5c66ac958ec7abe6331ed3ce9a92d0af8000afa05a9308f4ec69dc8e9c7fcdebc4711d673b0b211145d0a6be6d201f4d4c0
6
+ metadata.gz: 9a48aab6bd53e30c06b9209b580724386584c3125669a787d43aeb3a656ded4fac42850ab3c5e3bf22d1efa6b0f6fec94498af20b0f4c613d817290e4440f160
7
+ data.tar.gz: b61b313dc2cf9da4aa524ce8f985b6016532237f168f5eda7d89047dc9493f97a03eecdede3c484295264c9eaec6292740ad9fa53dfa7f0d89c3188630530b99
@@ -1,3 +1,7 @@
1
+ # 1.1.6
2
+
3
+ * Assortment of minor bugfixes
4
+
1
5
  # 1.1.5
2
6
 
3
7
  * bugfix re-release of 1.1.4
@@ -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, os_version, compile_option, and ruby_revision members track
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 os_version;
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
- /* Derived from kernel or libc version; intended to roughly correspond to when
71
- * ABIs have changed, requiring recompilation of native gems. */
72
- static uint32_t current_os_version;
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 get_os_version(void);
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
- current_os_version = get_os_version();
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
- fnv1a_64(const char *str)
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
- * The idea here is that we want a cache key member that changes when the OS
191
- * changes in such a way as to make existing compiled ISeqs unloadable.
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
- get_os_version(void)
204
+ get_ruby_platform(void)
195
205
  {
196
- #ifdef _WIN32
197
- return (uint32_t)GetVersion();
198
- #else
199
206
  uint64_t hash;
200
- struct utsname utsname;
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
- /* Not worth crashing if this fails; lose cache invalidation potential */
203
- if (uname(&utsname) < 0) return 0;
212
+ #ifdef _WIN32
213
+ return (uint32_t)(hash >> 32) ^ (uint32_t)GetVersion();
214
+ #else
215
+ struct utsname utsname;
204
216
 
205
- hash = fnv1a_64(utsname.version);
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
- #endif
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->os_version == k2->os_version &&
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->os_version = current_os_version;
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)
@@ -1,3 +1,3 @@
1
1
  module Bootsnap
2
- VERSION = "1.1.6.beta3"
2
+ VERSION = "1.1.6"
3
3
  end
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.beta3
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-08 00:00:00.000000000 Z
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: 1.3.1
156
+ version: '0'
157
157
  requirements: []
158
158
  rubyforge_project:
159
159
  rubygems_version: 2.6.14