oslo i18n using in lazy mode causes more file stats
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
oslo.i18n |
Fix Released
|
Wishlist
|
Unassigned |
Bug Description
I observed many openstack services and openstack component are searing for translation very frequently.
I just modified the basic example application and enabled
the lazy mode.
http://
Without lazy mode I just see an initial file search via strace,
but when the lazy mode gets enabled every message causes a file search.
These kind of extra searches just waste of time,
If the file was not there at the first execution, we should not expect it will be there at every log line print. Nobody expects a service needs to find and use an on the file changed/installed translation. Would be better
to make the normal execution faster.
This library is just a wrapper around gettext. In "non-lazy" mode, gettext is invoked when the string is encountered in the code and the results can be cached. This supports translating to one language. In lazy mode, we delay translation until the last possible moment to give the user the language they specify when making their API call. The dynamic nature of that approach means we can't cache the results of the translation, and need to call gettext more often. And gettext is searching for the message catalogs each time because it is being initialized.
We could potentially save some number of gettext translation objects based on the domain and language/locale.