Currently, we attempt to initialize translations machinery for all modules as soon as they are loaded, despite the fact in many contexts we do not need to display any translations (e.g. {{module list}}). We do this even for modules that do not have any translation files or marked strings.
We also attempt to cache translations after they're loaded, but not associated with any existing cache lifetimes. So the only way to cause a translation to be reloaded is to restart the process.
We should add a function to {{module.rb}} that loads a module's translations, then call it before we think we need module translations to be displayed (e.g. before compilation, or when running a puppet application). We should not load translations for things like file serving, in order to avoid doing unnecessary work. We should see if these optimizations are sufficient to reduce the performance impact before doing anything more drastic.
*Notes on decoupling module naming from locales/config.yaml project name* From comment below: {quote} As part of this, we should remove the requirement that the module have metadata (relies on forge_name) and remove the coupling of metadata naming and locales/config.yaml's project_name. {quote}
Benchmarks in puppet have shown a non-trivial performance degradation if there is a mismatch between the module's metadata name, and the locales/config.yaml's project_name: With matching names: {code} mkdir -p /var/folders/0_/6qt793gx6w706cq1q9kc0w780000gq/T/many_modules20171009-2426-1l58rtz user system total real Run 1 3.700000 0.460000 4.170000 ( 4.171436) Run 2 2.840000 0.130000 2.970000 ( 2.974983) Run 3 2.890000 0.120000 3.010000 ( 3.016188) Run 4 2.910000 0.130000 3.040000 ( 3.036231) Run 5 2.770000 0.150000 2.920000 ( 2.932649) Run 6 2.800000 0.120000 2.920000 ( 2.910116) Run 7 3.240000 0.110000 3.350000 ( 3.359197) Run 8 2.760000 0.150000 2.910000 ( 2.909707) Run 9 3.260000 0.150000 3.410000 ( 3.414169) Run 10 3.690000 0.140000 3.830000 ( 3.835340) > total: 30.860000 1.660000 32.530000 ( 32.560017) > avg: 3.086000 0.166000 3.253000 ( 3.256002) {code}
with mismatched names: {code} mkdir -p /var/folders/0_/6qt793gx6w706cq1q9kc0w780000gq/T/many_modules20171009-2350-11p565v user system total real Run 1 3.680000 0.460000 4.150000 ( 4.157170) Run 2 3.300000 0.250000 3.550000 ( 3.552481) Run 3 3.180000 0.250000 3.430000 ( 3.430290) Run 4 3.400000 0.260000 3.660000 ( 3.662123) Run 5 3.690000 0.310000 4.000000 ( 4.010465) Run 6 3.600000 0.260000 3.860000 ( 3.866366) Run 7 3.320000 0.250000 3.570000 ( 3.571592) Run 8 3.610000 0.320000 3.930000 ( 3.943484) Run 9 3.560000 0.310000 3.870000 ( 3.866563) Run 10 3.990000 0.260000 4.250000 ( 4.247610) > total: 35.330000 2.930000 38.270000 ( 38.308143) > avg: 3.533000 0.293000 3.827000 ( 3.830814) {code}
Note ~ 6 second cumulative runtime increase
----
Note that a further implication of how we're loading modules is that if modules don't have metadata, they [will not have a forge_name|https://github.com/puppetlabs/puppet/blob/5.3.1/lib/puppet/module.rb#L226-L229] and thus [initializing i18n will be skipped|https://github.com/puppetlabs/puppet/blob/5.3.1/lib/puppet/module.rb#L426].
|
|
|