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

WordPress Trac noreply at wordpress.org
Thu Feb 19 03:35:16 UTC 2015


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

Comment (by jbrinley):

 More statistics, from today's Slack conversation:

 nacin [18:16]
 > @jbrinley anything we can do to specifically improve upon any areas
 where it is slower? e.g. 12% slower for one callback.


 jbrinley [22:04]
 > @nacin: I tried to find a way to optimize the one callback case, but
 failed. Anything I tried was either less performant overall, or failed to
 correctly handle edge cases (like a hook with a single callback, but that
 callback adds other callbacks while it's running).
 >
 > The actual difference we're talking about is fairly minute. In a worst
 case scenario, where every hook that WP fires has a single callback
 assigned to it, 12% extra time running `do_action()` or `apply_filters()`
 adds approximately 0.01s to WP's total load time. But surely most of the
 hooks with one callback will be offset by other hooks with zero callbacks.
 When I load the home page of a clean install (2014 theme),
 `apply_filters()` or `do_action` is called 2520 times with zero callbacks
 vs 164 times with 1 callback.
 >
 > summary: .00044 seconds lost is more than offset by .00112 seconds
 gained

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


More information about the wp-trac mailing list