bootsnap 1.1.5 → 1.1.6.beta2
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/.travis.yml +1 -2
- data/README.md +5 -20
- data/dev.yml +1 -0
- data/ext/bootsnap/bootsnap.c +78 -30
- data/lib/bootsnap/bundler.rb +12 -0
- data/lib/bootsnap/load_path_cache/core_ext/active_support.rb +4 -0
- data/lib/bootsnap/load_path_cache/path.rb +1 -1
- data/lib/bootsnap/load_path_cache/path_scanner.rb +2 -1
- data/lib/bootsnap/setup.rb +4 -10
- data/lib/bootsnap/version.rb +1 -1
- data/lib/bootsnap.rb +1 -0
- metadata +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 269514b76977fe302e8e8bed9059ead9a2c9cf28
|
|
4
|
+
data.tar.gz: a66fd4b75f0b4fb211b998ded43f87aa31edc8b4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e3651625736c73f66e3380c5ca1514769707d5d605541a6f636c9fbb563cc2b3199bfc5baa26130106a158f02f66485bdd606f7db5ee47914e451a7ff4337f0d
|
|
7
|
+
data.tar.gz: e0ba55c3d695a8d91b4ba2aa0ca120ba530c7a665e66a882b8f1e966e846639399e5ea49cecc08aec7ba36b1329b08c84140e20f3aa34efa2902e4b35ebc0681
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# Bootsnap [](https://travis-ci.org/Shopify/bootsnap)
|
|
2
2
|
|
|
3
|
-
**Beta-quality. See [the last section of this README](#trustworthiness).**
|
|
4
|
-
|
|
5
3
|
Bootsnap is a library that plugs into Ruby, with optional support for `ActiveSupport` and `YAML`,
|
|
6
4
|
to optimize and cache expensive computations. See [How Does This Work](#how-does-this-work).
|
|
7
5
|
|
|
@@ -48,6 +46,11 @@ Bootsnap.setup(
|
|
|
48
46
|
'bootsnap')` using [this trick](https://github.com/Shopify/bootsnap/wiki/Bootlib::Require). This
|
|
49
47
|
will help optimize boot time further if you have an extremely large `$LOAD_PATH`.
|
|
50
48
|
|
|
49
|
+
Note: Bootsnap and [Spring](https://github.com/rails/spring) are orthogonal tools. While Bootsnap
|
|
50
|
+
speeds up the loading of individual source files, Spring keeps a copy of a pre-booted Rails process
|
|
51
|
+
on hand to completely skip parts of the boot process the next time it's needed. The two tools work
|
|
52
|
+
well together, and are both included in a newly-generated Rails applications by default.
|
|
53
|
+
|
|
51
54
|
## How does this work?
|
|
52
55
|
|
|
53
56
|
Bootsnap optimizes methods to cache results of expensive computations, and can be grouped
|
|
@@ -264,21 +267,3 @@ open /c/nope.bundle -> -1
|
|
|
264
267
|
```
|
|
265
268
|
# (nothing!)
|
|
266
269
|
```
|
|
267
|
-
|
|
268
|
-
## Trustworthiness
|
|
269
|
-
|
|
270
|
-
We use the `*_path_cache` features in production and haven't experienced any issues in a long time.
|
|
271
|
-
|
|
272
|
-
The `compile_cache_*` features work well for us in development on macOS. It should work on Linux,
|
|
273
|
-
and we intend to deploy it in production, but we haven't yet.
|
|
274
|
-
|
|
275
|
-
`disable_trace` should be completely safe, but we don't really use it because some people like to
|
|
276
|
-
use tools that make use of `trace` instructions.
|
|
277
|
-
|
|
278
|
-
| feature | where we're using it |
|
|
279
|
-
|-|-|
|
|
280
|
-
| `load_path_cache` | everywhere |
|
|
281
|
-
| `autoload_path_cache` | everywhere |
|
|
282
|
-
| `disable_trace` | nowhere, but it's safe unless you need tracing |
|
|
283
|
-
| `compile_cache_iseq` | development, but probably safe to use everywhere |
|
|
284
|
-
| `compile_cache_yaml` | development, but probably safe to use everywhere |
|
data/dev.yml
CHANGED
data/ext/bootsnap/bootsnap.c
CHANGED
|
@@ -92,8 +92,8 @@ static void bs_cache_path(const char * cachedir, const char * path, char ** cach
|
|
|
92
92
|
static int bs_read_key(int fd, struct bs_cache_key * key);
|
|
93
93
|
static int cache_key_equal(struct bs_cache_key * k1, struct bs_cache_key * k2);
|
|
94
94
|
static VALUE bs_fetch(char * path, VALUE path_v, char * cache_path, VALUE handler);
|
|
95
|
-
static int open_current_file(char * path, struct bs_cache_key * key);
|
|
96
|
-
static int fetch_cached_data(int fd, ssize_t data_size, VALUE handler, VALUE * output_data, int * exception_tag);
|
|
95
|
+
static int open_current_file(char * path, struct bs_cache_key * key, char ** errno_provenance);
|
|
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
98
|
static uint32_t get_os_version(void);
|
|
99
99
|
|
|
@@ -279,18 +279,22 @@ bs_rb_fetch(VALUE self, VALUE cachedir_v, VALUE path_v, VALUE handler)
|
|
|
279
279
|
* was loaded.
|
|
280
280
|
*/
|
|
281
281
|
static int
|
|
282
|
-
open_current_file(char * path, struct bs_cache_key * key)
|
|
282
|
+
open_current_file(char * path, struct bs_cache_key * key, char ** errno_provenance)
|
|
283
283
|
{
|
|
284
284
|
struct stat statbuf;
|
|
285
285
|
int fd;
|
|
286
286
|
|
|
287
287
|
fd = open(path, O_RDONLY);
|
|
288
|
-
if (fd < 0)
|
|
288
|
+
if (fd < 0) {
|
|
289
|
+
*errno_provenance = (char *)"bs_fetch:open_current_file:open";
|
|
290
|
+
return fd;
|
|
291
|
+
}
|
|
289
292
|
#ifdef _WIN32
|
|
290
293
|
setmode(fd, O_BINARY);
|
|
291
294
|
#endif
|
|
292
295
|
|
|
293
296
|
if (fstat(fd, &statbuf) < 0) {
|
|
297
|
+
*errno_provenance = (char *)"bs_fetch:open_current_file:fstat";
|
|
294
298
|
close(fd);
|
|
295
299
|
return -1;
|
|
296
300
|
}
|
|
@@ -336,12 +340,13 @@ bs_read_key(int fd, struct bs_cache_key * key)
|
|
|
336
340
|
* - ERROR_WITH_ERRNO (-1, errno is set)
|
|
337
341
|
*/
|
|
338
342
|
static int
|
|
339
|
-
open_cache_file(const char * path, struct bs_cache_key * key)
|
|
343
|
+
open_cache_file(const char * path, struct bs_cache_key * key, char ** errno_provenance)
|
|
340
344
|
{
|
|
341
345
|
int fd, res;
|
|
342
346
|
|
|
343
347
|
fd = open(path, O_RDONLY);
|
|
344
348
|
if (fd < 0) {
|
|
349
|
+
*errno_provenance = (char *)"bs_fetch:open_cache_file:open";
|
|
345
350
|
if (errno == ENOENT) return CACHE_MISSING_OR_INVALID;
|
|
346
351
|
return ERROR_WITH_ERRNO;
|
|
347
352
|
}
|
|
@@ -351,6 +356,7 @@ open_cache_file(const char * path, struct bs_cache_key * key)
|
|
|
351
356
|
|
|
352
357
|
res = bs_read_key(fd, key);
|
|
353
358
|
if (res < 0) {
|
|
359
|
+
*errno_provenance = (char *)"bs_fetch:open_cache_file:read";
|
|
354
360
|
close(fd);
|
|
355
361
|
return res;
|
|
356
362
|
}
|
|
@@ -374,7 +380,7 @@ open_cache_file(const char * path, struct bs_cache_key * key)
|
|
|
374
380
|
* or exception, will be the final data returnable to the user.
|
|
375
381
|
*/
|
|
376
382
|
static int
|
|
377
|
-
fetch_cached_data(int fd, ssize_t data_size, VALUE handler, VALUE * output_data, int * exception_tag)
|
|
383
|
+
fetch_cached_data(int fd, ssize_t data_size, VALUE handler, VALUE * output_data, int * exception_tag, char ** errno_provenance)
|
|
378
384
|
{
|
|
379
385
|
char * data = NULL;
|
|
380
386
|
ssize_t nread;
|
|
@@ -383,6 +389,7 @@ fetch_cached_data(int fd, ssize_t data_size, VALUE handler, VALUE * output_data,
|
|
|
383
389
|
VALUE storage_data;
|
|
384
390
|
|
|
385
391
|
if (data_size > 100000000000) {
|
|
392
|
+
*errno_provenance = (char *)"bs_fetch:fetch_cached_data:datasize";
|
|
386
393
|
errno = EINVAL; /* because wtf? */
|
|
387
394
|
ret = -1;
|
|
388
395
|
goto done;
|
|
@@ -390,6 +397,7 @@ fetch_cached_data(int fd, ssize_t data_size, VALUE handler, VALUE * output_data,
|
|
|
390
397
|
data = ALLOC_N(char, data_size);
|
|
391
398
|
nread = read(fd, data, data_size);
|
|
392
399
|
if (nread < 0) {
|
|
400
|
+
*errno_provenance = (char *)"bs_fetch:fetch_cached_data:read";
|
|
393
401
|
ret = -1;
|
|
394
402
|
goto done;
|
|
395
403
|
}
|
|
@@ -441,12 +449,12 @@ mkpath(char * file_path, mode_t mode)
|
|
|
441
449
|
* path.
|
|
442
450
|
*/
|
|
443
451
|
static int
|
|
444
|
-
atomic_write_cache_file(char * path, struct bs_cache_key * key, VALUE data)
|
|
452
|
+
atomic_write_cache_file(char * path, struct bs_cache_key * key, VALUE data, char ** errno_provenance)
|
|
445
453
|
{
|
|
446
454
|
char template[MAX_CACHEPATH_SIZE + 20];
|
|
447
455
|
char * dest;
|
|
448
456
|
char * tmp_path;
|
|
449
|
-
int fd;
|
|
457
|
+
int fd, ret;
|
|
450
458
|
ssize_t nwrite;
|
|
451
459
|
|
|
452
460
|
dest = strncpy(template, path, MAX_CACHEPATH_SIZE);
|
|
@@ -455,9 +463,15 @@ atomic_write_cache_file(char * path, struct bs_cache_key * key, VALUE data)
|
|
|
455
463
|
tmp_path = mktemp(template);
|
|
456
464
|
fd = open(tmp_path, O_WRONLY | O_CREAT, 0644);
|
|
457
465
|
if (fd < 0) {
|
|
458
|
-
if (mkpath(path, 0755) < 0)
|
|
466
|
+
if (mkpath(path, 0755) < 0) {
|
|
467
|
+
*errno_provenance = (char *)"bs_fetch:atomic_write_cache_file:mkpath";
|
|
468
|
+
return -1;
|
|
469
|
+
}
|
|
459
470
|
fd = open(tmp_path, O_WRONLY | O_CREAT, 0644);
|
|
460
|
-
if (fd < 0)
|
|
471
|
+
if (fd < 0) {
|
|
472
|
+
*errno_provenance = (char *)"bs_fetch:atomic_write_cache_file:open";
|
|
473
|
+
return -1;
|
|
474
|
+
}
|
|
461
475
|
}
|
|
462
476
|
#ifdef _WIN32
|
|
463
477
|
setmode(fd, O_BINARY);
|
|
@@ -465,8 +479,12 @@ atomic_write_cache_file(char * path, struct bs_cache_key * key, VALUE data)
|
|
|
465
479
|
|
|
466
480
|
key->data_size = RSTRING_LEN(data);
|
|
467
481
|
nwrite = write(fd, key, KEY_SIZE);
|
|
468
|
-
if (nwrite < 0)
|
|
482
|
+
if (nwrite < 0) {
|
|
483
|
+
*errno_provenance = (char *)"bs_fetch:atomic_write_cache_file:write";
|
|
484
|
+
return -1;
|
|
485
|
+
}
|
|
469
486
|
if (nwrite != KEY_SIZE) {
|
|
487
|
+
*errno_provenance = (char *)"bs_fetch:atomic_write_cache_file:keysize";
|
|
470
488
|
errno = EIO; /* Lies but whatever */
|
|
471
489
|
return -1;
|
|
472
490
|
}
|
|
@@ -474,12 +492,17 @@ atomic_write_cache_file(char * path, struct bs_cache_key * key, VALUE data)
|
|
|
474
492
|
nwrite = write(fd, RSTRING_PTR(data), RSTRING_LEN(data));
|
|
475
493
|
if (nwrite < 0) return -1;
|
|
476
494
|
if (nwrite != RSTRING_LEN(data)) {
|
|
495
|
+
*errno_provenance = (char *)"bs_fetch:atomic_write_cache_file:writelength";
|
|
477
496
|
errno = EIO; /* Lies but whatever */
|
|
478
497
|
return -1;
|
|
479
498
|
}
|
|
480
499
|
|
|
481
500
|
close(fd);
|
|
482
|
-
|
|
501
|
+
ret = rename(tmp_path, path);
|
|
502
|
+
if (ret < 0) {
|
|
503
|
+
*errno_provenance = (char *)"bs_fetch:atomic_write_cache_file:rename";
|
|
504
|
+
}
|
|
505
|
+
return ret;
|
|
483
506
|
}
|
|
484
507
|
|
|
485
508
|
/*
|
|
@@ -502,10 +525,15 @@ prot_exception_for_errno(VALUE err)
|
|
|
502
525
|
/* Read contents from an fd, whose contents are asserted to be +size+ bytes
|
|
503
526
|
* long, into a buffer */
|
|
504
527
|
static ssize_t
|
|
505
|
-
bs_read_contents(int fd, size_t size, char ** contents)
|
|
528
|
+
bs_read_contents(int fd, size_t size, char ** contents, char ** errno_provenance)
|
|
506
529
|
{
|
|
530
|
+
ssize_t nread;
|
|
507
531
|
*contents = ALLOC_N(char, size);
|
|
508
|
-
|
|
532
|
+
nread = read(fd, *contents, size);
|
|
533
|
+
if (nread < 0) {
|
|
534
|
+
*errno_provenance = (char *)"bs_fetch:bs_read_contents:read";
|
|
535
|
+
}
|
|
536
|
+
return nread;
|
|
509
537
|
}
|
|
510
538
|
|
|
511
539
|
/*
|
|
@@ -513,24 +541,24 @@ bs_read_contents(int fd, size_t size, char ** contents)
|
|
|
513
541
|
* Bootsnap::CompileCache::Native.fetch.
|
|
514
542
|
*
|
|
515
543
|
* There are three "formats" in use here:
|
|
516
|
-
* 1. "input"
|
|
544
|
+
* 1. "input" format, which is what we load from the source file;
|
|
517
545
|
* 2. "storage" format, which we write to the cache;
|
|
518
546
|
* 3. "output" format, which is what we return.
|
|
519
547
|
*
|
|
520
548
|
* E.g., For ISeq compilation:
|
|
521
|
-
* input:
|
|
549
|
+
* input: ruby source, as text
|
|
522
550
|
* storage: binary string (RubyVM::InstructionSequence#to_binary)
|
|
523
|
-
* output:
|
|
551
|
+
* output: Instance of RubyVM::InstructionSequence
|
|
524
552
|
*
|
|
525
553
|
* And for YAML:
|
|
526
|
-
* input:
|
|
554
|
+
* input: yaml as text
|
|
527
555
|
* storage: MessagePack or Marshal text
|
|
528
|
-
* output:
|
|
556
|
+
* output: ruby object, loaded from yaml/messagepack/marshal
|
|
529
557
|
*
|
|
530
|
-
*
|
|
531
|
-
* * storage_to_output(
|
|
532
|
-
* * input_to_output(
|
|
533
|
-
* * input_to_storage(
|
|
558
|
+
* A handler<I,S,O> passed in must support three messages:
|
|
559
|
+
* * storage_to_output(S) -> O
|
|
560
|
+
* * input_to_output(I) -> O
|
|
561
|
+
* * input_to_storage(I) -> S
|
|
534
562
|
* (input_to_storage may raise Bootsnap::CompileCache::Uncompilable, which
|
|
535
563
|
* will prevent caching and cause output to be generated with
|
|
536
564
|
* input_to_output)
|
|
@@ -559,6 +587,7 @@ bs_fetch(char * path, VALUE path_v, char * cache_path, VALUE handler)
|
|
|
559
587
|
char * contents = NULL;
|
|
560
588
|
int cache_fd = -1, current_fd = -1;
|
|
561
589
|
int res, valid_cache, exception_tag = 0;
|
|
590
|
+
char * errno_provenance = NULL;
|
|
562
591
|
|
|
563
592
|
VALUE input_data; /* data read from source file, e.g. YAML or ruby source */
|
|
564
593
|
VALUE storage_data; /* compiled data, e.g. msgpack / binary iseq */
|
|
@@ -567,11 +596,11 @@ bs_fetch(char * path, VALUE path_v, char * cache_path, VALUE handler)
|
|
|
567
596
|
VALUE exception; /* ruby exception object to raise instead of returning */
|
|
568
597
|
|
|
569
598
|
/* Open the source file and generate a cache key for it */
|
|
570
|
-
current_fd = open_current_file(path, ¤t_key);
|
|
599
|
+
current_fd = open_current_file(path, ¤t_key, &errno_provenance);
|
|
571
600
|
if (current_fd < 0) goto fail_errno;
|
|
572
601
|
|
|
573
602
|
/* Open the cache key if it exists, and read its cache key in */
|
|
574
|
-
cache_fd = open_cache_file(cache_path, &cached_key);
|
|
603
|
+
cache_fd = open_cache_file(cache_path, &cached_key, &errno_provenance);
|
|
575
604
|
if (cache_fd < 0 && cache_fd != CACHE_MISSING_OR_INVALID) goto fail_errno;
|
|
576
605
|
|
|
577
606
|
/* True if the cache existed and no invalidating changes have occurred since
|
|
@@ -580,7 +609,10 @@ bs_fetch(char * path, VALUE path_v, char * cache_path, VALUE handler)
|
|
|
580
609
|
|
|
581
610
|
if (valid_cache) {
|
|
582
611
|
/* Fetch the cache data and return it if we're able to load it successfully */
|
|
583
|
-
res = fetch_cached_data(
|
|
612
|
+
res = fetch_cached_data(
|
|
613
|
+
cache_fd, (ssize_t)cached_key.data_size, handler,
|
|
614
|
+
&output_data, &exception_tag, &errno_provenance
|
|
615
|
+
);
|
|
584
616
|
if (exception_tag != 0) goto raise;
|
|
585
617
|
else if (res == CACHE_MISSING_OR_INVALID) valid_cache = 0;
|
|
586
618
|
else if (res == ERROR_WITH_ERRNO) goto fail_errno;
|
|
@@ -591,7 +623,7 @@ bs_fetch(char * path, VALUE path_v, char * cache_path, VALUE handler)
|
|
|
591
623
|
/* Cache is stale, invalid, or missing. Regenerate and write it out. */
|
|
592
624
|
|
|
593
625
|
/* Read the contents of the source file into a buffer */
|
|
594
|
-
if (bs_read_contents(current_fd, current_key.size, &contents) < 0) goto fail_errno;
|
|
626
|
+
if (bs_read_contents(current_fd, current_key.size, &contents, &errno_provenance) < 0) goto fail_errno;
|
|
595
627
|
input_data = rb_str_new_static(contents, current_key.size);
|
|
596
628
|
|
|
597
629
|
/* Try to compile the input_data using input_to_storage(input_data) */
|
|
@@ -608,7 +640,7 @@ bs_fetch(char * path, VALUE path_v, char * cache_path, VALUE handler)
|
|
|
608
640
|
if (!RB_TYPE_P(storage_data, T_STRING)) goto invalid_type_storage_data;
|
|
609
641
|
|
|
610
642
|
/* Write the cache key and storage_data to the cache directory */
|
|
611
|
-
res = atomic_write_cache_file(cache_path, ¤t_key, storage_data);
|
|
643
|
+
res = atomic_write_cache_file(cache_path, ¤t_key, storage_data, &errno_provenance);
|
|
612
644
|
if (res < 0) goto fail_errno;
|
|
613
645
|
|
|
614
646
|
/* Having written the cache, now convert storage_data to output_data */
|
|
@@ -618,7 +650,10 @@ bs_fetch(char * path, VALUE path_v, char * cache_path, VALUE handler)
|
|
|
618
650
|
/* If output_data is nil, delete the cache entry and generate the output
|
|
619
651
|
* using input_to_output */
|
|
620
652
|
if (NIL_P(output_data)) {
|
|
621
|
-
if (unlink(cache_path) < 0)
|
|
653
|
+
if (unlink(cache_path) < 0) {
|
|
654
|
+
errno_provenance = (char *)"bs_fetch:unlink";
|
|
655
|
+
goto fail_errno;
|
|
656
|
+
}
|
|
622
657
|
bs_input_to_output(handler, input_data, &output_data, &exception_tag);
|
|
623
658
|
if (exception_tag != 0) goto raise;
|
|
624
659
|
}
|
|
@@ -637,6 +672,9 @@ fail_errno:
|
|
|
637
672
|
CLEANUP;
|
|
638
673
|
exception = rb_protect(prot_exception_for_errno, INT2FIX(errno), &res);
|
|
639
674
|
if (res) exception = rb_eStandardError;
|
|
675
|
+
if (errno_provenance != NULL) {
|
|
676
|
+
exception = rb_exc_new_str(exception, rb_str_new2(errno_provenance));
|
|
677
|
+
}
|
|
640
678
|
rb_exc_raise(exception);
|
|
641
679
|
__builtin_unreachable();
|
|
642
680
|
raise:
|
|
@@ -655,7 +693,17 @@ invalid_type_storage_data:
|
|
|
655
693
|
/********************* Handler Wrappers **************************************/
|
|
656
694
|
/*****************************************************************************
|
|
657
695
|
* Everything after this point in the file is just wrappers to deal with ruby's
|
|
658
|
-
* clunky method of handling exceptions from ruby methods invoked from C
|
|
696
|
+
* clunky method of handling exceptions from ruby methods invoked from C:
|
|
697
|
+
*
|
|
698
|
+
* In order to call a ruby method from C, while protecting against crashing in
|
|
699
|
+
* the event of an exception, we must call the method with rb_protect().
|
|
700
|
+
*
|
|
701
|
+
* rb_protect takes a C function and precisely one argument; however, we want
|
|
702
|
+
* to pass multiple arguments, so we must create structs to wrap them up.
|
|
703
|
+
*
|
|
704
|
+
* These functions return an exception_tag, which, if non-zero, indicates an
|
|
705
|
+
* exception that should be jumped to with rb_jump_tag after cleaning up
|
|
706
|
+
* allocated resources.
|
|
659
707
|
*/
|
|
660
708
|
|
|
661
709
|
struct s2o_data {
|
|
@@ -45,6 +45,10 @@ module Bootsnap
|
|
|
45
45
|
# NoMethodError is a NameError, but we only want to handle actual
|
|
46
46
|
# NameError instances.
|
|
47
47
|
raise unless e.class == NameError
|
|
48
|
+
# We can only confidently handle cases when *this* constant fails
|
|
49
|
+
# to load, not other constants referred to by it.
|
|
50
|
+
raise unless e.name == const_name
|
|
51
|
+
# If the constant was actually loaded, something else went wrong?
|
|
48
52
|
raise if from_mod.const_defined?(const_name)
|
|
49
53
|
CoreExt::ActiveSupport.without_bootsnap_cache { super }
|
|
50
54
|
end
|
|
@@ -99,7 +99,7 @@ module Bootsnap
|
|
|
99
99
|
@stability ||= begin
|
|
100
100
|
if Gem.path.detect { |p| expanded_path.start_with?(p.to_s) }
|
|
101
101
|
STABLE
|
|
102
|
-
elsif expanded_path.start_with?(Bundler.bundle_path.to_s)
|
|
102
|
+
elsif Bootsnap.bundler? && expanded_path.start_with?(Bundler.bundle_path.to_s)
|
|
103
103
|
STABLE
|
|
104
104
|
elsif expanded_path.start_with?(RUBY_LIBDIR) && !expanded_path.start_with?(RUBY_SITEDIR)
|
|
105
105
|
STABLE
|
|
@@ -15,7 +15,8 @@ module Bootsnap
|
|
|
15
15
|
REQUIRABLES_AND_DIRS = "/{,*/**/}*{#{DOT_RB},#{DL_EXTENSIONS.join(',')},/}"
|
|
16
16
|
NORMALIZE_NATIVE_EXTENSIONS = !DL_EXTENSIONS.include?(LoadPathCache::DOT_SO)
|
|
17
17
|
ALTERNATIVE_NATIVE_EXTENSIONS_PATTERN = /\.(o|bundle|dylib)\z/
|
|
18
|
-
BUNDLE_PATH =
|
|
18
|
+
BUNDLE_PATH = Bootsnap.bundler? ?
|
|
19
|
+
(Bundler.bundle_path.cleanpath.to_s << LoadPathCache::SLASH).freeze : ''.freeze
|
|
19
20
|
|
|
20
21
|
def self.call(path)
|
|
21
22
|
path = path.to_s
|
data/lib/bootsnap/setup.rb
CHANGED
|
@@ -4,16 +4,10 @@ env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || ENV['ENV']
|
|
|
4
4
|
development_mode = ['', nil, 'development'].include?(env)
|
|
5
5
|
|
|
6
6
|
# only enable on 'ruby' (MRI), POSIX (darin, linux, *bsd), and >= 2.3.0
|
|
7
|
-
enable_cc =
|
|
8
|
-
RUBY_ENGINE == 'ruby' &&
|
|
9
|
-
RUBY_PLATFORM =~ /darwin|linux|bsd/ &&
|
|
10
|
-
RUBY_VERSION
|
|
11
|
-
.split('.') # ["1", "9", "3"]
|
|
12
|
-
.map(&:to_i) # [1, 9, 3]
|
|
13
|
-
.zip([2, 3, -1]) # [[1, 2], [9, 3], [3, -1]]
|
|
14
|
-
.map { |a, b| a <=> b } # [-1, 1, 1]
|
|
15
|
-
.detect { |e| !e.zero? } # -1
|
|
16
|
-
.==(1) # false
|
|
7
|
+
enable_cc =
|
|
8
|
+
RUBY_ENGINE == 'ruby' &&
|
|
9
|
+
RUBY_PLATFORM =~ /darwin|linux|bsd/ &&
|
|
10
|
+
Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.3.0")
|
|
17
11
|
|
|
18
12
|
cache_dir = ENV['BOOTSNAP_CACHE_DIR']
|
|
19
13
|
unless cache_dir
|
data/lib/bootsnap/version.rb
CHANGED
data/lib/bootsnap.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.
|
|
4
|
+
version: 1.1.6.beta2
|
|
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-
|
|
11
|
+
date: 2017-12-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -121,6 +121,7 @@ files:
|
|
|
121
121
|
- ext/bootsnap/bootsnap.h
|
|
122
122
|
- ext/bootsnap/extconf.rb
|
|
123
123
|
- lib/bootsnap.rb
|
|
124
|
+
- lib/bootsnap/bundler.rb
|
|
124
125
|
- lib/bootsnap/compile_cache.rb
|
|
125
126
|
- lib/bootsnap/compile_cache/iseq.rb
|
|
126
127
|
- lib/bootsnap/compile_cache/yaml.rb
|
|
@@ -150,12 +151,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
150
151
|
version: 2.0.0
|
|
151
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
153
|
requirements:
|
|
153
|
-
- - "
|
|
154
|
+
- - ">"
|
|
154
155
|
- !ruby/object:Gem::Version
|
|
155
|
-
version:
|
|
156
|
+
version: 1.3.1
|
|
156
157
|
requirements: []
|
|
157
158
|
rubyforge_project:
|
|
158
|
-
rubygems_version: 2.6.
|
|
159
|
+
rubygems_version: 2.6.14
|
|
159
160
|
signing_key:
|
|
160
161
|
specification_version: 4
|
|
161
162
|
summary: Boot large ruby/rails apps faster
|