bootsnap 1.4.4 → 1.4.5

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
  SHA256:
3
- metadata.gz: db7809e0e5fa0f4a018dd7254cb99619ada5c7c26947db858d9b56f29dc76249
4
- data.tar.gz: 1d9d8eed648ce29ea43307d246089a9ea116c6148681a9c43393d458c77049dd
3
+ metadata.gz: be54a60d54f32f824d5c2fdccf189cdcb5409d1848c55f6e654fe44ace1d3f21
4
+ data.tar.gz: c6239c30984a936b76e218c2b1292a7e72d817d3e4847a6c58f0121c1e3068dc
5
5
  SHA512:
6
- metadata.gz: fc0befd695ab9ef47a405fea7e83b856a422f70f8f59bd2737067b4951dc20c85210d562d332e5161a3dd7816258b14295e1a91a7e2ec62a8d8dc0e5bc0fb3bf
7
- data.tar.gz: 7a408b74a5e57dc0feaf2fdfd47930a4f22f048888f0643b316e3a139fc35eaeec358599a8846dde45395db55e8f66d398704de651ba67f4cd0bdfc7d9190469
6
+ metadata.gz: c251990457406cd51726eec8d62e0e1028bbeade6e24f266cb743d6f00f53650841beed9ee8e1795c78febd18ea234691125920c16aa5a95031718a28619bb31
7
+ data.tar.gz: 554a885bf2264f088618c41864fb84069d0664b35af0ae4b619c8fbb1cf285c80fad564d36845161f8044c35c6b53a33e66f27eb75c6715f25869af2795c97f6
@@ -1,3 +1,8 @@
1
+ # 1.4.5
2
+
3
+ * MRI 2.7 support
4
+ * Fixed concurrency bugs
5
+
1
6
  # 1.4.4
2
7
 
3
8
  * Disable ISeq cache in `bootsnap/setup` by default in Ruby 2.5
@@ -96,6 +96,7 @@ static int cache_key_equal(struct bs_cache_key * k1, struct bs_cache_key * k2);
96
96
  static VALUE bs_fetch(char * path, VALUE path_v, char * cache_path, VALUE handler);
97
97
  static int open_current_file(char * path, struct bs_cache_key * key, char ** errno_provenance);
98
98
  static int fetch_cached_data(int fd, ssize_t data_size, VALUE handler, VALUE * output_data, int * exception_tag, char ** errno_provenance);
99
+ static uint32_t get_ruby_revision(void);
99
100
  static uint32_t get_ruby_platform(void);
100
101
 
101
102
  /*
@@ -136,7 +137,7 @@ Init_bootsnap(void)
136
137
  rb_mBootsnap_CompileCache_Native = rb_define_module_under(rb_mBootsnap_CompileCache, "Native");
137
138
  rb_eBootsnap_CompileCache_Uncompilable = rb_define_class_under(rb_mBootsnap_CompileCache, "Uncompilable", rb_eStandardError);
138
139
 
139
- current_ruby_revision = FIX2INT(rb_const_get(rb_cObject, rb_intern("RUBY_REVISION")));
140
+ current_ruby_revision = get_ruby_revision();
140
141
  current_ruby_platform = get_ruby_platform();
141
142
 
142
143
  uncompilable = rb_intern("__bootsnap_uncompilable__");
@@ -196,6 +197,26 @@ fnv1a_64(const char *str)
196
197
  return fnv1a_64_iter(h, str);
197
198
  }
198
199
 
200
+ /*
201
+ * Ruby's revision may be Integer or String. CRuby 2.7 or later uses
202
+ * Git commit ID as revision. It's String.
203
+ */
204
+ static uint32_t
205
+ get_ruby_revision(void)
206
+ {
207
+ VALUE ruby_revision;
208
+
209
+ ruby_revision = rb_const_get(rb_cObject, rb_intern("RUBY_REVISION"));
210
+ if (RB_TYPE_P(ruby_revision, RUBY_T_FIXNUM)) {
211
+ return FIX2INT(ruby_revision);
212
+ } else {
213
+ uint64_t hash;
214
+
215
+ hash = fnv1a_64(StringValueCStr(ruby_revision));
216
+ return (uint32_t)(hash >> 32);
217
+ }
218
+ }
219
+
199
220
  /*
200
221
  * When ruby's version doesn't change, but it's recompiled on a different OS
201
222
  * (or OS version), we need to invalidate the cache.
@@ -28,7 +28,7 @@ module Bootsnap
28
28
  raise(
29
29
  PermissionError,
30
30
  "bootsnap doesn't have permission to write cache entries in '#{cpath}' " \
31
- "(or, less likely, doesn't have permisison to read '#{path}')",
31
+ "(or, less likely, doesn't have permission to read '#{path}')",
32
32
  )
33
33
  end
34
34
 
@@ -11,7 +11,8 @@ module Bootsnap
11
11
 
12
12
  def initialize(store_path)
13
13
  @store_path = store_path
14
- @in_txn = false
14
+ # TODO: Remove conditional once Ruby 2.2 support is dropped.
15
+ @txn_mutex = defined?(::Mutex) ? ::Mutex.new : ::Thread::Mutex.new
15
16
  @dirty = false
16
17
  load_data
17
18
  end
@@ -21,7 +22,7 @@ module Bootsnap
21
22
  end
22
23
 
23
24
  def fetch(key)
24
- raise(SetOutsideTransactionNotAllowed) unless @in_txn
25
+ raise(SetOutsideTransactionNotAllowed) unless @txn_mutex.owned?
25
26
  v = get(key)
26
27
  unless v
27
28
  @dirty = true
@@ -32,7 +33,7 @@ module Bootsnap
32
33
  end
33
34
 
34
35
  def set(key, value)
35
- raise(SetOutsideTransactionNotAllowed) unless @in_txn
36
+ raise(SetOutsideTransactionNotAllowed) unless @txn_mutex.owned?
36
37
  if value != @data[key]
37
38
  @dirty = true
38
39
  @data[key] = value
@@ -40,12 +41,14 @@ module Bootsnap
40
41
  end
41
42
 
42
43
  def transaction
43
- raise(NestedTransactionError) if @in_txn
44
- @in_txn = true
45
- yield
46
- ensure
47
- commit_transaction
48
- @in_txn = false
44
+ raise(NestedTransactionError) if @txn_mutex.owned?
45
+ @txn_mutex.synchronize do
46
+ begin
47
+ yield
48
+ ensure
49
+ commit_transaction
50
+ end
51
+ end
49
52
  end
50
53
 
51
54
  private
@@ -1,3 +1,3 @@
1
1
  module Bootsnap
2
- VERSION = "1.4.4"
2
+ VERSION = "1.4.5"
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.4.4
4
+ version: 1.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burke Libbey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-24 00:00:00.000000000 Z
11
+ date: 2019-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -167,8 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  requirements: []
170
- rubyforge_project:
171
- rubygems_version: 2.7.6
170
+ rubygems_version: 3.0.2
172
171
  signing_key:
173
172
  specification_version: 4
174
173
  summary: Boot large ruby/rails apps faster