Project

General

Profile

Bug #14092

Multidomain translations slow hammer down

Added by Tomáš Strachota over 3 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
High
Category:
Hammer core
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

When hammer is installed with multiple plugins the startup slows down. Profiling showed we're loosing quite some time in fast-gettext's initialisation and translation methods. It loads all available .mo files for all languages in all plugins regardless what language is used. Another inefficiency lies in multidomain translations we're using (one domain per plugin). For each translation fast-gettext iterates over all domains until it finds the key.

Simple measurement for hammer with plugins:

  • hammer_cli_foreman
  • hammer_cli_foreman_bootdisk
  • hammer_cli_foreman_discovery
  • hammer_cli_foreman_docker
  • hammer_cli_gutterball
  • hammer_cli_import
  • hammer_cli_katello

Standard hammer configuration on ruby 1.9.3:

time hammer --help > /dev/null
real    0m1.584s
user    0m1.453s
sys    0m0.130s

With only one translation domain:

time hammer --help > /dev/null
real    0m1.109s
user    0m1.017s
sys    0m0.092s

The solution seems to be to create custom fast-gettext translation repository that would merge the keys at load time to get rid of the search loops in each translation. Loading the .mo files lazily might also improve the performance.

Associated revisions

Revision 6e28b70f (diff)
Added by Tomas Strachota about 3 years ago

Fixes #14092 - gettext speed improvements (#198)

- gettext speed improvements
- compatibility with fast_gettext < 1.2.0
- fast_gettext 1.2.0 dropped ruby 2.0 support. This patch adds compatibility with older versions.

History

#1 Updated by Tomáš Strachota over 3 years ago

  • Description updated (diff)

#2 Updated by Tomáš Strachota over 3 years ago

  • Bugzilla link set to 1315660

#3 Updated by The Foreman Bot over 3 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/hammer-cli/pull/198 added

#4 Updated by Tomáš Strachota over 3 years ago

  • Description updated (diff)

#5 Updated by Tomáš Strachota about 3 years ago

  • Target version set to 115

#6 Updated by Marek Hulán about 3 years ago

  • Target version changed from 115 to 1.6.3

#7 Updated by Tomáš Strachota about 3 years ago

  • Target version changed from 1.6.3 to 1.6.0

#8 Updated by Anonymous about 3 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF