You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Within our company we are using the route_translator gem for a long time already but we noticed that within our setup we generate over 11k routes and most of them are not unique. This has a profound impact on the memory usage of our app.
By diving into this we noticed that we have a lot of duplicate routes due to our setup. Currently we are using brand specific locales and falling back on generic locales when needed. But in many cases these translations are actually duplicated.
The following locales will cause 2 routes being generated with the same path. (made up example to reflect the issue)
nl_stw:
people: mensennl:
people: mensen
resources:people
Output:
GET /mensen(.:format) people#index {:locale=>"nl_stw"}
GET /mensen(.:format) people#index {:locale=>"nl"}
etc..
To combat this I dug into route_translator and started tinkering with it's internals to find a way to not generate duplicate routes and using the fallbacks to still use the correct route translation.
Within the following PR (to my own fork) i've made an example implementation and i'm wondering if this would be something that this project is interested in or that it falls outside of the scope of this project. https://github.com/xtr3me/route_translator/pull/2/files
This PR reduces the amount of routes for us from 11k to around 2200 and it drops the memory usage by almost 100mb.
The downside is that we cannot use the locale param, but from our testing this never worked for us as Rails will select the first matching route it finds.
The PR itself still needs tests to be added and a general cleanup of the code. But I will only go forward with that if it has any chance it will be incorporated upstream.
TLDR; Is this something route_translator wants to embed or does it fall out of scope?
The text was updated successfully, but these errors were encountered:
Within our company we are using the route_translator gem for a long time already but we noticed that within our setup we generate over 11k routes and most of them are not unique. This has a profound impact on the memory usage of our app.
By diving into this we noticed that we have a lot of duplicate routes due to our setup. Currently we are using brand specific locales and falling back on generic locales when needed. But in many cases these translations are actually duplicated.
The following locales will cause 2 routes being generated with the same path. (made up example to reflect the issue)
Output:
To combat this I dug into route_translator and started tinkering with it's internals to find a way to not generate duplicate routes and using the fallbacks to still use the correct route translation.
Within the following PR (to my own fork) i've made an example implementation and i'm wondering if this would be something that this project is interested in or that it falls outside of the scope of this project.
https://github.com/xtr3me/route_translator/pull/2/files
This PR reduces the amount of routes for us from 11k to around 2200 and it drops the memory usage by almost 100mb.
The downside is that we cannot use the locale param, but from our testing this never worked for us as Rails will select the first matching route it finds.
The PR itself still needs tests to be added and a general cleanup of the code. But I will only go forward with that if it has any chance it will be incorporated upstream.
TLDR; Is this something route_translator wants to embed or does it fall out of scope?
The text was updated successfully, but these errors were encountered: