Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-8024

Only load module translations when necessary

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • PUP 5.3.4
    • None
    • Hide

      Gettext is only initialized for modules when it is needed in order to display translations

      Show
      Gettext is only initialized for modules when it is needed in order to display translations
    • Platform Core
    • Platform Core KANBAN
    • Not Needed
    • No Action

    Description

      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 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:

      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.

      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:

      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)
      

      with mismatched names:

      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)
      

      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 and thus initializing i18n will be skipped.

      Attachments

        Issue Links

          Activity

            People

              eric.delaney Eric Delaney
              maggie Maggie Dreyer
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support