[wp-trac] [WordPress Trac] #14889: Memory Comparison Broken / WordPress Memory Limit

WordPress Trac wp-trac at lists.automattic.com
Fri May 13 21:11:46 UTC 2011


#14889: Memory Comparison Broken / WordPress Memory Limit
---------------------------------+-----------------------------
 Reporter:  hakre                |       Owner:
     Type:  defect (bug)         |      Status:  new
 Priority:  normal               |   Milestone:  Future Release
Component:  General              |     Version:  3.0
 Severity:  normal               |  Resolution:
 Keywords:  has-patch 3.2-early  |
---------------------------------+-----------------------------

Comment (by chrisbliss18):

 I decided to revisit this problem and find a way to change the code to be
 just as fast but while adding the ability to allow the WP_MEMORY_LIMIT
 define to use units other than M. I believe that I have succeeded.

 After many benchmarks and tweaks, I got the code to average out to about
 the same speed as my last patch (in my trials, the speed difference is
 around +-5%) while only adding four lines of code. I'm a bit of a proud
 code parent. The new patch is chrisbliss18-patch.2.diff.

 Note that one of the big speed improvements came from removing the
 function_exists check for memory_get_usage. PHP 5.2.1 removed the need to
 compile PHP with the --enable-memory-limit compile-time directive in order
 to manipulate the memory_limit. Since 3.2 has a minimum PHP version of
 5.2.4, there isn't a need for this expensive check.

 For those that are interested in the benchmarks, I've updated my
 benchmarking script to also include this new algorithm. Here are the stats
 while running it on my current dev system:

 {{{
 wp_function
 ==========================
 Trials:           250247
 Total Time:       39.26492857933
 Average Time:     0.00015690469248115
 Runs per Sec:     6373.2956878911
 Success Rate:     0.5
 Speed Difference: 0

 patch_function_original
 ==========================
 Trials:           249581
 Total Time:       95.880811691284
 Average Time:     0.00038416711084291
 Runs per Sec:     2603.0338667094
 Success Rate:     1
 Speed Difference: 1.4418944630847

 patch_function_new
 ==========================
 Trials:           250765
 Total Time:       53.182673454285
 Average Time:     0.00021208172374249
 Runs per Sec:     4715.1634867614
 Success Rate:     1
 Speed Difference: 0.35445740966611

 patch_function_new_complete
 ==========================
 Trials:           249407
 Total Time:       52.663097858429
 Average Time:     0.00021115324693545
 Runs per Sec:     4735.896864071
 Success Rate:     1
 Speed Difference: 0.34122484781881
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14889#comment:15>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list