• Resolved Holoduke99

    (@holoduke99)


    Hi,

    I have been working on a new project for months. My site is slow, 30 secs pero load, more than 1GB memory per load.

    I did an strace to process and I see 4700 errors: No such file or directory

    This is an example:

    access(“MY_PATH/wp-content/plugins/loco-translate/src/compat/WCJ_General.php”, F_OK) = -1 ENOENT (No such file or directory)

    At this example it tries to access WCJ_General.php. But it try lo access all other classes at plugins folder (4730 times).

    I do not know:
    – If I have an error at PHP config.
    – If this is loco-translate normal working.
    – If there is a problem at loco translate.

    I tested at PHP 8.1 8.2 and 8.3

    Any idea would be appreciated.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Tim W

    (@timwhitlock)

    Loco Translate has an autoloader. You can see it here.

    You are correct, it considers all missing classes so it can load polyfills, and/or raise warnings. This is “normal”.

    A couple of things…

    1. I’m surprised a simple file check slows your site down. Are you saying this happens 4,700 times in a single script execution? That is a very large number of classes being requested, and not very “normal” in my experience.
    2. I’ve not had cause to consider this until now, but this compat functionality is actually only required in WordPress admin, and in fact only on Loco Translate admin pages. I will look at removing this for public pages in the next release. I’ll be interested to see if this makes a difference to your site performance.
    Thread Starter Holoduke99

    (@holoduke99)

    Thanks for reply.

    I work on a big WP project. Hundreds of custom ACF fields. 58 plugins active. 7 languages. Unique actions/filter 7889. Total actions/filters 3175995

    I experience this problem with other plugins too, I already opened tickets to others plugins support teams. I appreciate your response. Now I know im in the right path.

    I promise I will debug time load before and after apply your next release and I will update ticket.

    Thanks again for considering it for next release.

    • This reply was modified 1 year ago by Holoduke99.
    Plugin Author Tim W

    (@timwhitlock)

    I can understand a code base having thousands of classes on disk. The surprising part is that all 4,700 could possibly be used in the same single process. Autoloaders won’t be consulted unless a class definition is actively requested. (or class_exists is called with autoload=true).

    I’ve just deployed an experimental change to the development version which simplifies the Loco Translate auto-loader on all pages outside of its own admin screens. Please have a go and let me know if you see any improvement. All it will do now for “foreign” classes, is check the ‘Loco_’ prefix.

    I could probably simplify it further, but note other autoloaders may still be consulted, even if mine isn’t. You might want to dump out spl_autoload_functions to see how many are running.

    Thread Starter Holoduke99

    (@holoduke99)

    It takes average 1.5 secs less. I expected more impact, but this is a great. Each second less is important ??

    I think we can close ticket.

    Thank you for your time.

    Plugin Author Tim W

    (@timwhitlock)

    Glad to have made a difference.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP8.x loco-translate/src/compat try to access all the other classes’ is closed to new replies.