Improve rake gettext:lint performance
What does this MR do?
Improves the performance of rake gettext:lint
by setting the locale once per .po
file rather than twice per translation.
Before:
bundle exec rake gettext:lint 79.83s user 3.89s system 98% cpu 1:25.22 total
bundle exec rake gettext:lint 82.78s user 3.93s system 98% cpu 1:28.31 total
bundle exec rake gettext:lint 83.31s user 3.88s system 98% cpu 1:28.95 total
After:
bundle exec rake gettext:lint 43.67s user 3.67s system 96% cpu 49.016 total
bundle exec rake gettext:lint 42.22s user 3.85s system 96% cpu 47.827 total
bundle exec rake gettext:lint 45.35s user 3.76s system 95% cpu 51.288 total
I checked https://gitlab.com/gitlab-org/gitlab's recent jobs to see how often gettext:lint
is ran inside the static-analysis 2/4
job, and in 3 hours it was ran 78 times (I would have gone back further, but was mindful of API calls). These jobs had an average bin/rake gettext:lint
duration of 94 seconds.
Assuming the 3 hours was typical, assuming all the additional time was CPU, and assuming a run time reduction of 40 seconds, that would equate to 624 jobs in 24 hours with roughly 7 hours reduced CPU time per day for a shared runner, assuming my math is correct and gitlab's runners approximate my development environment. Developers waiting for gettext:lint
to run would also see a productivity improvement. :)
Screenshots (strongly suggested)
Before:
After: