[wp-trac] [WordPress Trac] #27122: Optimization for PHP FPM

WordPress Trac noreply at wordpress.org
Fri Feb 14 00:28:09 UTC 2014


#27122: Optimization for PHP FPM
-------------------------+------------------------------
 Reporter:  dunglas      |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  General      |     Version:  trunk
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:  performance
-------------------------+------------------------------

Comment (by dunglas):

 Sorry, I was not aware that this function is used in other places.

 I agree with your solution @dd32 except that this is better in a
 performance point of view to call {{{ fastcgi_finish_request() }}} before
 the last call to {{{ ob_end_flush() }}} and it's even better to not call
 it at all like in the Symfony implementation.

 A compromise can be to register {{{ fastcgi_finish_request() }}} to the
 shutdown hook with a priority of 1 if the function exists and (always if
 the function exists) to not register {{{ wp_ob_end_flush_all() }}} to this
 hook.

 This will maximizes performances on FPM and will not break existing code
 because the behavior of {{{ wp_ob_end_flush_all() }}} is not modified.

 If you think this solution is fine I'll submit a new patch tomorrow.

 Replying to [comment:1 dd32]:
 > I don't think this is a safe optimization to make unfortunately.
 >
 > Consider the scenario where `wp_ob_end_flush_all()` is called mid-
 pageload by plugins for example, which we also do in core:
 > https://core.trac.wordpress.org/browser/trunk/src/wp-
 admin/includes/misc.php#L290
 > https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes
 /class-wp-upgrader-skins.php#L251
 >
 > Perhaps a safer option, would be to conditionally add
 `fastcgi_finish_request` to the `shutdown` action at priority 2? as you
 can see `wp_ob_end_flush_all ()` being used here:
 > https://core.trac.wordpress.org/browser/trunk/src/wp-includes/default-
 filters.php#L250
 >
 > What do you think @dunglas?

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


More information about the wp-trac mailing list