[wp-trac] [WordPress Trac] #17817: do_action/apply_filters/etc. recursion on same filter kills underlying call

WordPress Trac noreply at wordpress.org
Mon Mar 10 02:42:07 UTC 2014


#17817: do_action/apply_filters/etc. recursion on same filter kills underlying call
-------------------------------------------------+-------------------------
 Reporter:  kernfel                              |       Owner:
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  Future
Component:  Plugins                              |  Release
 Severity:  normal                               |     Version:  2.2
 Keywords:  has-patch needs-testing dev-         |  Resolution:
  feedback                                       |     Focuses:
-------------------------------------------------+-------------------------

Comment (by jbrinley):

 Here's my next attempt. Executive summary: Still slower (but more
 reasonably so) in some cases, slightly faster in the most common case,
 backwards compatible, passes all unit tests. Let's ship it.

 Details:

 Results of benchmarking using https://gist.github.com/jbrinley/9458582:

 {{{
 Running 10000 times with 0 callbacks
 Total Time (Old): 0.093368
 Average Time (Old): 0.000004
 Total Time (New): 0.078037
 Average Time (New): 0.000004
 New runs in 83.58% of the time of old.

 Running 10000 times with 3 callbacks
 Total Time (Old): 1.299951
 Average Time (Old): 0.000064
 Total Time (New): 1.822003
 Average Time (New): 0.000117
 New runs in 140.16% of the time of old.

 Running 10000 times with 15 callbacks
 Total Time (Old): 4.006840
 Average Time (Old): 0.000184
 Total Time (New): 6.443348
 Average Time (New): 0.000390
 New runs in 160.81% of the time of old.

 Running 1000 times with 300 callbacks
 Total Time (Old): 8.345846
 Average Time (Old): 0.003690
 Total Time (New): 13.177368
 Average Time (New): 0.007553
 New runs in 157.89% of the time of old.

 Running 100 times with 3000 callbacks
 Total Time (Old): 8.087688
 Average Time (Old): 0.031045
 Total Time (New): 10.641660
 Average Time (New): 0.052878
 New runs in 131.58% of the time of old.
 }}}


 You'll notice that with 0 callbacks, the new code is actually a bit more
 performant than the existing code. For the vast majority of hooks, this
 will be the case. In all other cases, the new code for running do_action()
 takes 30-60% longer than the old code.

 Translating this into actual page loads using ab on a stock WP install
 (svn trunk at 27490, twentyfourteen theme):

 Existing code:

 {{{
 Connection Times (ms)
               min  mean[+/-sd] median   max
 Connect:        0    0   0.1      0       0
 Processing:   177  190  11.0    191     209
 Waiting:      177  188   8.8    191     205
 Total:        177  190  11.0    192     209
 }}}

 17817.4.patch:

 {{{
 Connection Times (ms)
               min  mean[+/-sd] median   max
 Connect:        0    0   0.1      0       0
 Processing:   175  186   7.3    189     196
 Waiting:      175  185   7.3    189     196
 Total:        175  186   7.3    189     197
 }}}

 A statistically insignificant 2% ''faster'' with the new code, largely due
 to the fact that most hooks don't have any callbacks most of the time.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/17817#comment:48>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list