Project

General

Profile

« Previous | Next » 

Revision b6b6ffc0

Added by Lukáš Zapletal about 3 years ago

Fixes #31717 - lazy-load fast_gettext for faster boot (#8275)

It's because we switch over all 20 languages to actually pull language name in the native language into a list of available languages. We use that in three places: settings page, user page and GraphQL.

This can be easily be lazy-loaded, so those 2 seconds are not wasted during startup. Only few languages are usually used, definitely not all of them.

Ewoud had a good point that this would prevent from sharing the translation cache (about 20MB) so we actually preload translations, but only in production. This way we can enjoy startups of Foreman in a dev environment by 2 seconds (which is actually 17% by local testing) while preloading everything in production (where the operation is a bit faster and reboot time not so painful).

View differences:

config/puma/production.rb
# === Puma control rack application ===
activate_control_app "unix://#{run_dir}/sockets/pumactl.sock"
# Loading and initializing of all gettext languages takes about 100ms per language
# in development environment and little less on production. Let's eager load languages
# for production before forking to save memory on CoW operating systems.
before_fork do
FastGettext.human_available_locales
end

Also available in: Unified diff