-
Notifications
You must be signed in to change notification settings - Fork 85
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
Allow fallbacks to be initialized at boot time #481
Comments
There are a bunch of issues around fallbacks:
Now that v1.0 has been released and the basic framework has stabilized, I'd really like to solve them all for 1.1 because fallbacks is such a popular feature, but I'm not actually a user of fallbacks myself so have a hard time seeing these issues. 🤔 |
Out of curiosity, what did your patch look like? |
As pointed out in shioyama#481, I18n fallbacks [are lazy-initialized by default](https://github.com/ruby-i18n/i18n/blob/4709391dceab9096d5988576f93935843023a6ef/lib/i18n/locale/fallbacks.rb#L71). This can be problematic in production environments, particularly with forking appservers, since: 1. The first request pays the initialization cost 2. Memory usage is duplicated across appserver processes rather than taking advantage of copy-on-write This is a draft of a way to mitigate these problems. Readability isn't great since the `i18n` library doesn't seem to have an API to explicitly initialize fallbacks. Instead we're just looping through each locale and referencing it so that `i18n` will initialize it. Considerations: 1. We probably don't want this behavior in development, how should we account for that? 2. Ideally this behavior would be configurable, what is the right place for that configuration to live? This could potentially address (1). 3. Would this be considered a breaking change to have turned on by default?
I tested this out locally on our own project, where we are migrating from Globalize to Mobility 1.x during an upgrade to Rails 5. |
I don't have time to implement this, so closing. |
First of all, thank you so much for this amazing library!
One thing I noticed recently, is that the I18n fallbacks instance that is created for each attribute is lazy loaded. This is great for development, but in production, particularly with forking appservers, this can lead to increased memory usage and latency for the first request.
I was able to work around this with a monkey patch, but it would be great if something like the railtie Rails uses to initialize i18n could be introduced.
Thanks again!
The text was updated successfully, but these errors were encountered: