-
-
Notifications
You must be signed in to change notification settings - Fork 411
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
Major performance regression with enforce_available_locales = true #230
Comments
+1 I'm also having the same problem. my rspec tests suddenly become an order (or two) of magnitude slower than usual. |
Any metrics greatly appreciated. |
Not sure what you expect exactly, but any simple test makes it obvious. TL;DR: "min 111.7 avg 154.2 max 335.1 median 128.5" => "min 149.8 avg 223.8 max 484.8 median 169.5" httperf benchmark data (on localhost):
|
Thanks for the info - can you indicate which Backend you're using and how you're calling the
This is actually the essence of the last security update unfortunately. |
I use the simple YAML backend. Some optimizations to accelerate the lookup part can probably done though. Some ideas:
On my side I prefer to validate user-submitted locale strings when submitted instead of at each use. Makes much more sense for me, and this is much faster (I'm generally doing many I18n.t lookups per view). |
@tigrish I haven't done any benchmark yet, but I think that we could probably make the I imagine that could alleviate the issue reported here considerably. @cmaion how many available locales do you have? |
All default Rails locales. Never bothered to trim them, nor did I see the need for that. Should I?
Ok so some quick benchmark material here that might be of interest:
=> currently spending 1.2ms per translation performed (probably not accounting for generated garbage that will need to be cleaned up later on) |
I can confirm that there is a huge performance hit going on here. We have a rails app, that was running rails 4.0.3. When we upgraded to 4.0.4, we saw a huge performance hit. After countless hours of debugging, we figured out that this is the root cause, since Putting |
@NielsKSchjoedt thanks for the report and detailed graphs. I'll try to take a look at this soon and see if we can improve the way the enforce locales is being handled, if anyone else does it before me. |
Cache the available_locales in a local Set, so we can lookup, and check for inclusions faster. [fixes ruby-i18n#230]
The validity of config.locale is inforced in Config#locale=. Related ruby-i18n#230 and ruby-i18n#249.
The validity of config.locale is inforced in Config#locale=. Related ruby-i18n#230 and ruby-i18n#249.
@cmaion @NielsKSchjoedt I've just merged a fix in master that should bring performance back to an acceptable level, almost the same as before as we could benchmark. I plan to review this implementation in a next minor version, but for now I want to release a patched one with this perf fix and a couple other minor things already in master. If you could try those and report back, that'd be great. Thank you again for reporting and helping on this one. |
The validity of config.locale is inforced in Config#locale=. Related ruby-i18n#230 and ruby-i18n#249.
The validity of config.locale is inforced in Config#locale=. Related ruby-i18n#230 and ruby-i18n#249.
The validity of config.locale is inforced in Config#locale=. Related ruby-i18n#230 and ruby-i18n#249.
Hi guys,
FYI, setting enforce_available_locales to true on 0.6.9 has a major performance hit.
On my (large) Rails (3.2.16) app, avg response time increases by +40-50% by setting this to true. Setting it back to false seems to bring response times back to normal (still need to observe this for a couple of days though).
Cedric
The text was updated successfully, but these errors were encountered: