Opened 4 years ago
Closed 4 years ago
#10972 closed enhancement (fixed)
Improve sanitize_post() calling
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.9 |
| Component: | Performance | Version: | 2.9 |
| Severity: | normal | Keywords: | has-patch |
| Cc: |
Description
http://core.trac.wordpress.org/changeset/11282 resulted in a 5% performance regression.
sanitize_post() is called on every get_post(), which is used almost everywhere such as in commonly-called template functions (the_title, get_permalink, etc.).
A better solution than reverting the commit is to call sanitize_post() once only for a post: before storing in wp_cache_add() and for wp_query->posts. Instead of for example 16 times for each post in default theme.
This patch restores the performance lost by changeset 11282.
Attachments (4)
Change History (14)
- Summary changed from Changeset 11282 performance regression - and no need to sanitize_post more than once to Improve sanitize_post() calling
Perhaps we can move the loop from _sanitize_the_posts() directly into WP_Query::get_posts(). That way it is run even if filters are suppressed and we avoid the pass by value overhead incurred by anything attached to a filter.
See also the patch on #10801 which avoids extra filtering in some places.
Ok, looking good! Performance for 10972.diff
Average total page load time (ab -c 1 -n 100 http://example.org) for new 2.9.0-rare install 1 post front page org: 49ms fix: 47ms 10 post front page org: 115ms fix: 95ms
Numbers are stable.

Only sanitize_post() once