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

WordPress Trac noreply at wordpress.org
Sun Nov 17 21:47:10 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 run some performance benchmarking on this patch, using the code at
 https://gist.github.com/jbrinley/7518483.

 Running 10000 times with 3 callbacks
 Total Time (Old): 0.887964
 Average Time (Old): 0.000042
 Total Time (New): 1.961968
 Average Time (New): 0.000149

 Running 10000 times with 15 callbacks
 Total Time (Old): 3.754449
 Average Time (Old): 0.000160
 Total Time (New): 8.169822
 Average Time (New): 0.000606

 Running 10000 times with 150 callbacks
 Total Time (Old): 38.625702
 Average Time (Old): 0.001561
 Total Time (New): 184.439555
 Average Time (New): 0.016029

 Summary: calling do_action/apply_filters with the new iterator is less
 performant. With callbacks on three random priorities, it runs in about
 354% of the time. With 15 random callbacks, that increases to 404%. Crank
 it up to 150 different priorities, and that increases to 1026%.

 I would love for those numbers to be smaller, but a path thither is not
 clear to me. Using a global $merged_filters or similar doesn't work with
 nested hooks. If anyone has any suggestions, I'd appreciate a comment
 here.

 How do those numbers translate to real-world performance impact? On a
 stock WP install on my test server, apply_filters increases from 66ms to
 88ms. I also see a negligible gain of a couple of ms in add_filter by
 removing the unset on $merged_filters;

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


More information about the wp-trac mailing list