polylang / dynamo

Improves the WordPress translations performance
GNU General Public License v2.0
6 stars 1 forks source link

Investigate possible new performance improvements #4

Open Chouby opened 3 years ago

Chouby commented 3 years ago

This issue is a summary of ideas that could be implemented in the future if they are worth it.

Mte90 commented 2 years ago

I am trying to understand the difference compared to the actual implementation in WordPress but the readme and from the code I don't find anything useful. Taking as example also this that has object cache and use the php gettext module.

Chouby commented 2 years ago

There are 2 different methods.

  1. Used by WordPress. Load all the strings from the file and process them to be able to make the translation easily. The first step (load the file and process all strings) is slow. The translation is fast.
  2. Used by the original GNU Gettext. Load only the file headers and tables to find strings. Search for a string in the file only when you actually need to translate it. The first step is very fast compared to first method. The translation is slower compared to the first method.

If you need to translate all the strings included in the file, then the first method is the best. If you need to translate only a few strings avalaible in the file, then the second method is best.

DynaMo currently implements only the second method. #1 explains some of the choices that I have made.

Taking as example also this that has object cache and use the php gettext module.

I am not sure to understand what you mean. However, since you mention object cache, I have plans to try to take profit of it. Although I am still experimenting with it, this will probably be a completely different implementation compared to the uncached version. As for PHP Gettext module, I have no experience with it and currently have no plans with it.

Mte90 commented 2 years ago

Thanks for the explanation, really worth it (as I am one of the contributor to https://core.trac.wordpress.org/ticket/17268). There is the gettext module natively by PHP since years so you don't need anymore to parse the binary file in PHP and this should improve the performances a lot. It is used by https://github.com/aucor/dynamic-mo-loader, the author of this library suggested to check this library so this is the reason why I am here.