From f05f5fde0ffa71e39ec75b4619fad77c8ed8f8ea Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Thu, 13 May 2021 14:16:01 +0800 Subject: [PATCH] PERF: Preload `JsLocaleHelper.load_translations` for default locale. (#13041) In production, each Unicorn child process will currently hold the default locale in memory on first load. Instead, we should preload it in the Unicorn master process so that the memory is immediately shared when forking. Also, the translations are only memoized on first load now and is adding considerable overhead to the first few requests after a fresh boot. --- lib/discourse.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/discourse.rb b/lib/discourse.rb index 6d188b98e8e..ea2a3cbafda 100644 --- a/lib/discourse.rb +++ b/lib/discourse.rb @@ -933,6 +933,8 @@ module Discourse # this will force Cppjieba to preload if any site has it # enabled allowing it to be reused between all child processes Search.prepare_data("test") + + JsLocaleHelper.load_translations(SiteSetting.default_locale) end [