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

WordPress Trac noreply at wordpress.org
Tue Nov 19 16:57:09 UTC 2013


#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 Release
Component:  Plugins                  |     Version:  3.4.1
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |
-------------------------------------+-----------------------------

Comment (by jbrinley):

 I've attached a new version, 17817.3.patch. This one is a bit more
 invasive, changing the way the $wp_filter global works (it's now an object
 containing an array of WP_Hook objects). This allows the iterators to
 watch for changes to filters, enabling a more efficient algorithm for
 iterating over the priorities.

 Running the same benchmarking script (slightly modified to account for the
 new data structure):

 Running 10000 times with 3 callbacks
 Total Time (Old): 0.957014
 Average Time (Old): 0.000042
 Total Time (New): 2.570118
 Average Time (New): 0.000155

 Difference: 369%

 Running 10000 times with 15 callbacks
 Total Time (Old): 3.978540
 Average Time (Old): 0.000155
 Total Time (New): 9.040840
 Average Time (New): 0.000469

 Difference: 302%

 Running 1000 times with 300 callbacks
 Total Time (Old): 8.850893
 Average Time (Old): 0.003229
 Total Time (New): 17.300127
 Average Time (New): 0.007968

 Difference: 246%

 Running 1000 times with 3000 callbacks
 Total Time (Old): 88.171389
 Average Time (Old): 0.027288
 Total Time (New): 157.092921
 Average Time (New): 0.059824

 Difference: 219%

 Summary: still less performant, but the difference actually decreases now
 as the number of callbacks increases.

 On real page loads, I'm seeing about a 3% increase in total load time
 (increasing from ~660ms to ~680ms on my server) when profiling with
 xdebug. Using ab, I see an increase of about 5% (from ~190ms to ~200ms).

 This still passes all unit tests, including when run with the flag "--
 group hooks,21169,17817,9968".

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


More information about the wp-trac mailing list