Make WordPress Core

Opened 21 years ago

Closed 21 years ago

Last modified 20 years ago

#2048 closed defect (bug) (fixed)

Pings affect admin load times

Reported by: skeltoac Owned by: ryan
Priority: high Milestone:
Component: Optimization Version: 2.0
Severity: critical Keywords: bg|has-patch bg|commit
Cc: Focuses:

Description

My testing showed that JS is delayed until all iframes are loaded. This can take several seconds when there is even a small number of pings to execute. No header manipulation was successful at reducing the load time.

Here's a patch. It removes the iframe and runs execute-pings.php asynchronously by calling fsockopen with a timeout of 0.01. This is done by a function spawn_pinger that is called within wp_insert_post() and only when post_status=='publish' and pings are on.

An added benefit is that spawn_pinger will be called for all post saves and edits, including bookmarklet, sidebar and xmlrpc. Previously, any posts published or edited via these methods would not be pinged until someone with the authority to edit those posts logged in and used the admin screens.

It also fixes a bug: an attempt to repeat a trackback would cause that url to remain in to_ping indefinitely. It also trims to_ping after each update to eliminate unused spaces.

Attachments (1)

argyle.diff (5.7 KB ) - added by skeltoac 21 years ago.

Download all attachments as: .zip

Change History (5)

@skeltoac
21 years ago

#1 @matt
21 years ago

http://www.mikeindustries.com/blog/archive/2004/09/sifr2-kick-the-tires

Perhaps instead of onload we should have a script block called in the footer action. (This is for TinyMCE too.)

I'm not crazy about the fsockopen call, I still think we should be able to do this async in JS. Wouldn't we need a stream_set_timeout() anyway in the PHP? We've run into bugs before with how gzip and buffers interact and that holding up loads.

#2 @skeltoac
21 years ago

The fsockopen call mimics the one in the IXR_Client object used for pingbacks, as well as the one in our own trackback() function. So if the fsockopen call in spawn_pinger() doesn't work on a server, pingbacks and trackbacks are already broken on that server. It does not introduce any new dependencies.

The timeout is set to 0.01 seconds in the fsockopen call so it doesn't wait. I tested this with 30 pings at a time and had 100% of the pings arrive at their destinations. My admin page routinely completed loading before the third ping arrived from the spawned process.

It might be trivial, but it might be good to add an fclose() after the fput().

Involving the user agent in the process is unnecessary. Also, if you depend on JS to do spawn the ping processor, I think you have to list JS among the requirements.

Regarding optimizing the JS, we already have and use addLoadEvent(). We could use that to register functions to be fired by a sort of hook in the footer. I'll open a new ticket for that.

#3 @ryan
21 years ago

  • Resolutionfixed
  • Status newclosed

(In [3317]) New asyncronous ping method. fixes #2048

#4 @(none)
20 years ago

  • Milestone 2.0

Milestone 2.0 deleted

Note: See TracTickets for help on using tickets.