-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
An attempt to load only necessary locales on the fly #2169
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
amatsuda
force-pushed
the
load_less_locales
branch
from
October 20, 2020 14:45
74d3aa9
to
1a303c0
Compare
Zeragamba
approved these changes
Oct 26, 2020
changes look good to me, and the tests are passing. Thanks! |
vbrazo
added a commit
that referenced
this pull request
Nov 25, 2020
* Rollback PR #2169 * Add changelog * Bump version to 2.15.1
This was referenced Mar 11, 2021
This was referenced Mar 15, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue#
No-Story
Description:
This patch attempts not to always load all bundled locale files.
Motivation:
Faker bundles so many I18n resources for various locales in the gem package, but indeed our real-world applications do not usually use all these locales. In my case, number of locales that we use in our tests are usually one or two.
That means, most of locales that Faker loads are consuming our time and memory per each test run although we never use them.
It'd be nicer if Faker loads the YAML files only for "the locales that we would use" i.e.
available_locales
.Strategy:
Before this patch, Faker was telling I18n to load all bundled locale files at the very top level.
Instead, this patch suggests to load the ones that correspond to
I18n.available_locales
(note that the implementation is based on the assumption that each YAML file has the name of the locale that it contains).In consideration of the case where
I18n.available_locales
value is not yet configured when the ruby process loads this library but being configured somewhere in the application initialization process, this patch tries to postpone loading YAML files as late as possible.As a side effect, starting up a ruby process that bundles Faker but does not use Faker would become faster and less memory-consuming.
Note:
This PR would conflict with my previous PR #2167 but of course I'm happy to rebase whichever one.