heroku / heroku/heroku-buildpack-ruby

Bootsnap cache incorrect or not being used?

Open
#979 26 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
785
Forks
1.8k
Avg merge
1d 9h
Merged PRs (30d)
8

Description

## Linked internal tickets

- 952389

## Issue

The bootsnap cache is present after a deploy:

```
$ heroku run bash
~ $ du -hs tmp/cache
64M tmp/cache
~ $ ls tmp/cache
bootsnap-compile-cache bootsnap-load-path-cache
```

However if a `rails` process runs, the cache size doubles:

```
~ $ rails runner puts 'done' >> /dev/null
~ $ du -hs tmp/cache
125M tmp/cache
```

And running the same command twice makes it faster, this makes me think that bootstrap isn't being used:

```
$ heroku run bash
Running bash on ⬢ issuetriage... up, run.2775 (Standard-1X)
~ $ time rails runner puts "done"
# ...
real 0m7.197s
user 0m5.760s
sys 0m1.048s
~ $ time rails runner puts "done"
# ...
real 0m2.953s
user 0m2.384s
sys 0m0.492s
```

We need to investigate why. My first guess would be that the difference between build and runtime file structure prevents the original cache from being used. But that's just a guess.

## Update

The workaround is to use this feature:

```
$ heroku labs:enable build-in-app-dir -a
```

Referenced in this comment https://github.com/heroku/heroku-buildpack-ruby/issues/979#issuecomment-792720228

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the repeated `rails runner puts "done"` timing and inspecting `tmp/cache` before and after it runs. Compare the build-time and runtime file structures and the Bootsnap cache paths; the issue names no source files or tests. Done means explaining why the deployed cache is not reused and verifying whether `build-in-app-dir` resolves the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
build-system, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.