Closed n-rodriguez closed 10 months ago
I came up with this solution :
in bin/bootsnap-paths
:
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler'
{
# rubygems
'cable_ready' => ['/app/'],
'devise' => ['/app/'],
'turbo-rails' => ['/app/', '/config/'],
'rack-test' => ['/lib/rack/test/'],
'devise-otp' => ['/app/'],
'pghero' => ['/app/', '/config/'],
'rails-pg-extras' => ['/app/', '/config/'],
'devise_masquerade' => ['/app/'],
'sentry-rails' => ['/app/'],
'punching_bag' => ['/app/'],
# github
'crono' => ['/app/', '/config/'],
'redis_web_manager' => ['/app/', '/config/'],
'smart_listing' => ['/app/', '/config/'],
'health_monitor' => ['/config/'],
}.each do |gem_name, paths|
spec = Bundler.load.specs.find{ |s| s.name == gem_name }
paths.each do |path|
puts "#{spec.full_gem_path}#{path}"
end
end
bin/bootsnap precompile --gemfile app/ config/ lib/ vendor/engines/ $(bin/bootsnap-paths)
I no longer have any misses in container's logs.
Yes, this a consequence of Rails no longer adding autoloaded paths into the load path. We could probably look for app/
directories in gems, it wouldn't hurt, and is an easy fix.
But note that compiling 100% is nice but not strictly necessary.
But note that compiling 100% is nice but not strictly necessary.
Yes, but I want to avoid unecessary work at application boot.
Yes, but I want to avoid unecessary work at application boot.
Of course, just saying if e.g 0.2%
of files aren't precompiled, it likely won't make a measurable difference.
Still, I'll see to add gem/app
directories in the default compiled paths.
Still, I'll see to add
gem/app
directories in the default compiled paths.
So fast! Thank you!
So fast! Thank you!
Welcome. I probably won't cut a release just yet as I have some other changes I'm trying to make, but you can probably point your Gemfile at the repo.
but you can probably point your Gemfile at the repo.
Yep, done, merci!
Hi there!
I've enabled bootsnap logs in my Rails docker containers (1 container with puma / 3 containers with sidekiq / 1 container with crono) and found that some paths were not pre-compiled by bootsnap.
All are Rails engines files (under
<gem>/app
or<gem>/config
:(I've sorted logs output for better readability, the logs are the same for the 5 containers)
Bootsnap cache is created when building Docker images in CI :
and set to
readonly
inproduction
:I'm thinking about adding all this paths to
bin/bootsnap precompile
but I'd like to know if there is a better of way to add this paths to bootsnap precompilation.Thank you!