[wp-trac] [WordPress Trac] #10165: New implementation of MO file reader

WordPress Trac wp-trac at lists.automattic.com
Mon Jun 15 00:32:48 GMT 2009


#10165: New implementation of MO file reader
-------------------------+--------------------------------------------------
 Reporter:  soletan      |       Owner:  nbachiyski         
     Type:  enhancement  |      Status:  new                
 Priority:  normal       |   Milestone:  Unassigned         
Component:  i18n         |     Version:  2.8                
 Severity:  normal       |    Keywords:  l10n MO performance
-------------------------+--------------------------------------------------
 On moving from a Debian-driven virtual server to one of my dedicated root
 server running Gentoo Linux I had to encounter poor performance in
 Wordpress on every click. Other sites hosted on same server respond within
 a second at most while Wordpress 2.8 took about 10-15 seconds on each
 click.

 I started to upgrade packages, tried to performance-tune Apache and MySQL
 etc. without any remarkable success. And so I tried to locate the part of
 code in WP wasting so much time. Finally I stopped on method
 import_from_file() of class MO in wp-includes/pmo/mo.php.

 I'm running WP with German localization available from de.wordpress.org.
 de_DE.mo takes 300KB disk spaces and about 8 seconds to load with your
 current class MO here. I did some investigations on the used code and saw
 potential to improve its performance, thus started to implement my own MO
 file reader omitting all that POMOReader stuff etc. Finally i got a linear
 method reading (at least my) MO file up to four times faster.
 While server is emerging and compiling in background (e.g. compiling gcc
 and glibc) benchmarking existing MO file reader and my implementation
 resulted in a 8s vs. 2s runtime. BTW: other sites hosted on same server
 didn't remarkably slow down due to background compilation processes.

 In addition to reading MO files faster the class tries to utilize
 wp_cache_* interface (which seems to be useless at the moment, isn't it)
 and it tries to completely work without instances of class
 Translation_Entry, which I consider to take much more memory than a normal
 hash (As I tried to produce instances on successfully parsing MO file
 performance decreased remarkably by estimated 10%.)

 I'd like to provide my class here as-is since I didn't find the time to
 test it with other MO files or check if it's properly implementing API of
 class Translation.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/10165>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list