Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Investigate possible new performance improvements #4

Open
3 of 4 tasks
Chouby opened this issue Nov 29, 2021 · 3 comments
Open
3 of 4 tasks

Investigate possible new performance improvements #4

Chouby opened this issue Nov 29, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@Chouby
Copy link
Contributor

Chouby commented Nov 29, 2021

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

  • Take profit of object cache if present (this feature was included in WPPP). See Add object cache support #10
  • Share the hash evaluation when looking for a string in multiple files of one domain (typically the default domain). This could be done by storing an array of already evaluated hash values in a static properties ( so shared across all instances of Hash_Search ).
  • Don't store the plural forms in $this->originals and thus avoid testing the existence of plural forms to use only strcmp() in Binary_Search. See Don't store plural forms in search handlers cache #8
  • Is it useful to store original strings in $this->originals in Hash_Search? This seems to be useful for about 10% of the strings of the default domain.
@Chouby Chouby added the enhancement New feature or request label Nov 29, 2021
@Mte90
Copy link

Mte90 commented Dec 7, 2021

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
Copy link
Contributor Author

Chouby commented Dec 8, 2021

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
Copy link

Mte90 commented Dec 9, 2021

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants