New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The same cache seems used for different Ruby versions #384
Comments
👋 the ruby version is collected here: bootsnap/ext/bootsnap/bootsnap.c Lines 246 to 264 in a0aa3d2
It's basically If you think there's a better key, I'm totally open to update it. |
Using |
The cache entry contain a "version" header. If the header doesn't match, it acts as a cache miss and is regenerated.
I think you are right, that file was extracted in 3.1: ruby/ruby@12a0a89 The version guard is only for the compile cache (iseq etc). I think the error you did hit was a load path cache, which doesn't have such guard (IIRC). I'll try to dig a bit more into it later on (just got back from vacations, so I have tons of things to deal with first). |
Fix: #384 Until now it was assume that if the `$LOAD_PATH` was identical, then the content of the paths would be too. However from one minor ruby version to another, the layout of the stdlib can change. So if the newer version is installed in the same place than the previous one, it might cause the load path cache to be invalid. So we store `RUBY_DESCRIPTION` in the cache and make sure it matches before reusing the cache.
Fix: #384 Until now it was assume that if the `$LOAD_PATH` was identical, then the content of the paths would be too. However from one minor ruby version to another, the layout of the stdlib can change. So if the newer version is installed in the same place than the previous one, it might cause the load path cache to be invalid. So we store `RUBY_DESCRIPTION` in the cache and make sure it matches before reusing the cache.
Fix: #384 Until now it was assume that if the `$LOAD_PATH` was identical, then the content of the paths would be too. However from one minor ruby version to another, the layout of the stdlib can change. So if the newer version is installed in the same place than the previous one, it might cause the load path cache to be invalid. So we store `RUBY_DESCRIPTION` in the cache and make sure it matches before reusing the cache.
Before Shopify/yjit-bench#69 (review) I and @noahgibbs noticed that Bootsnap has an invalid cache when running the
erubi_rails
benchmark with e.g. 3.1-dev, 3.1.0 and 3.0.x.It seems the cache is not separated per Ruby version.
rm -rf tmp/cache/bootsnap
is a workaround, but hard to remember, and the error can be quite confusing.Should bootsnap care about this?
It seems not so uncommon to use e.g. different Ruby releases to run a Rails app, and Rails seems to just use the default bootsnap cache path.
One issue is if CRuby dev versions are "supported" they report the same RUBY_VERSION even though many things including the ABI, the stdlib files, the bytecode format, etc might change. Maybe using RUBY_REVISION (the commit) is the only safe way then.
The text was updated successfully, but these errors were encountered: