WordPress.org

Support

Support » Plugins and Hacks » qTranslate » evidence on how *slow* and inefficient qTranslate is … please do something

evidence on how *slow* and inefficient qTranslate is … please do something

  • I’m not the first one to experience this. I have a normal WP 3.5.1 installation (only a handful of plugins). I have only two languages. This page is also actually very easy on translation without any calls to __(), _(), etc, other than what WP does internally in the loop — actually the page template I have has fixed language titles and meta, and no comments.

    I profiled this page with qTranslate disabled and with qTranslate enabled. The numbers speak for themselves. Yes, that is 5 (five) times slower when qTranslate is enabled!

    qTranslate DISABLED:

    https://www.dropbox.com/s/84zfwnuky8qynim/no-qT-Cumul-Time.png
    https://www.dropbox.com/s/t900cw3zbj6d5g5/No-qT-Own-Time.png
    https://www.dropbox.com/s/uk3miie2tiyfvov/No-qT-Calls.png

    qTranslate ENABLED:

    https://www.dropbox.com/s/0zoatuyzu5682to/qT-Cumul-Time.png
    https://www.dropbox.com/s/q8rwrfs2nsde646/qT-Own-Time.png
    https://www.dropbox.com/s/8o871hedu4zcr31/qT-Calls.png

    The time is in milliseconds … 1 second vs 5 seconds page load time.

    You can see the ridiculously high number of calls to functions such as qtrans_isEnabled(), qtrans_use(), preg_replace(), in_array(), etc. A lot of these are unnecessary, and most are expensive. You don’t need preg_replace() all the time. If you absolutely have to use it and must call it so many thousands of times, using the same regex many times, then make sure you analyze and precompile the regex (use the S modifier) so that it doesn’t have to to compile it on every call. Don’t use preg_replace() when you can use str_replace(). Don’t use recursive functions if you can do it in a for/foreach loop. And so on and so forth.

    There are so many inefficient aspects to the qTranslate code causing it to be so slow that it is becomes a real pain to actually fix … I wanted to but gave up realizing I lack the time. I like qTranslate’s idea of storing all languages in the same post (although it could be improved) but I’m seriously thinking of giving up on it because
    – of how slow it is
    – the lack of support and replies from the author

    Is the author still around? Could he please at least reply to this and maybe state whether he’s going to consider improving the code?

    Cheers.

    p.s. Did I mention the ghastly function names, e.g. qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage() ?

    http://wordpress.org/extend/plugins/qtranslate/

Viewing 15 replies - 16 through 30 (of 36 total)
  • I understand why you do your own plugin, because patches etc don’t work really well.
    It improves fur sure, but still take time with this plugin.
    Even qtranslate slug.
    I removed some code, commented some parts, replaced some pre_reg etc, still slow for google
    Continuing…

    Do you know a good debugger, easy to install etc?
    Because some tools like xdebug are not recommanded on production servers.

    I try P3 plugin
    http://wordpress.org/extend/plugins/p3-profiler/
    maybe those
    http://wordpress.org/extend/plugins/askapache-debug-viewer/
    http://wordpress.org/extend/plugins/debug-this/

    based on
    http://blog.slo-host.com/tag/qtranslate/

    I’ve never had issues with Xdebug as far as PHP debuggers go.

    I optimized a few parts of qTranslate functions quite heavily and will post my patches soon.

    In fact, I may even release a very small plugin that patches qTranslate on the fly, which people can just install and use together with qTranslate to make it faster. It’s part of a bigger plugin I am writing.

    Stay tuned.

    Thank you normadize

    Thank you for all these optimizations. qTranslate is driving me nuts as well, but I don’t know of any alternative.

    Could I ask, which version are you applying these mods to?

    And would it be too much to ask that you provide a link to your full optimized version?

    Thanks!

    I’ll try to find time to do this but I’m pretty heavily swamped with work at the moment.

    I’m waiting in line, too.
    I think qTranslate is a powerful tool, but it’s a shame the author stopped working on it.
    When I needed this plugin, it was the best of them, do you know if things have changed now?
    Because, as normadice says, maybe it’s moment to move on…

    BTW, thanks for your work, guys.

    I’m also waiting for the optimized version… thx normadize for your great work! 🙂

    the code in qtrans_use doesn’t work with shortcodes ([:en]). I changed it like this and now it works:

    $re = ‘/<!–:[a-z]{2}–>|\[:[a-z]{2}\]/’;

    Also, another problem: with the iterator by reference I get an error:
    An iterator cannot be used with foreach by reference

    So I had to change it to

    foreach ($text as $t)

    @leoloso: what version of PHP are you using? I never had that issue with PHP 5.3 or PHP 5.4. Arrays or objects can be used with references in foreach() and the iterator var would be a reference to the actual array value or object property (faster for big and nested stuff).

    5.2.17

    are you suggesting then I ask my hosting provider to update PHP?

    I upgraded to PHP 5.3, 5.4 and 5.5, but the iteration by reference never worked (doing a Google Search of the error, most results also say it doesn’t work)

    foreach loops with references (to modify directly the contents of arrays/objects) is definitely supported and has been supported for the longest time: http://php.net/manual/en/control-structures.foreach.php

    The following tests were done on PHP 5.3.23, but should work just the same for lower versions.

    $a = array ('foo', 'bar');
    foreach ($a as &$value)
        $value .= ' here!';

    Outputs, as expected:

    Array
    (
        [0] => foo here!
        [1] => bar here!
    )

    Same with objects:

    class A {
        public $foo = 'foo';
        public $bar = 'bar';
    }
    $a = new A;
    foreach ($a as &$prop)
        $prop .= ' here!';
    print_r($a);

    Outputs, as expected:

    A Object
    (
        [foo] => foo here!
        [bar] => bar here!
    )

    It seems there’s something fishy on your end.

Viewing 15 replies - 16 through 30 (of 36 total)
  • The topic ‘evidence on how *slow* and inefficient qTranslate is … please do something’ is closed to new replies.
Skip to toolbar