Bug #14750
closedPerformance issue with Link Library
Added by Raffi Khatchadourian about 3 years ago. Updated about 3 years ago.
0%
Description
I feel as if the new version of Link Library has some significant performance issues (see this post). Do we have any page caching plug-ins that can help?
Updated by Boone Gorges about 3 years ago
- Status changed from New to Reporter Feedback
We don't use static page caching plugins on the Commons - they don't work well with our infrastructure (large multisite network). In any case, this kind of caching layer is usually bypassed when viewing the site as a logged-in user, so this kind of cache would only paper over an underlying performance issue.
Can you say more about the nature of the performance issues you're seeing? In my tests, it seems like the page content takes a couple seconds longer than expected to render - does this accurately reflect what you're seeing? (I should also note that the pageload was even more severely hampered when I originally tested, because of a blocking call to a Google Analytics script - I've got tools set up on my machine to prevent GA requests from connecting, which was causing a super long hangup when loading the page. It was more reasonable when I disabled this block.)
I've got some query monitoring tools in place to detect potential issues, and I can see that (a) the page in question generates a lot of uncached database queries, and (b) some of those queries are pretty slow. The slowness is generally on the order of ~0.1s, but when there's a couple dozen queries of this form, the page generation time gets to be quite long. The queries have the general form:
SELECT wp_2880_posts.* FROM wp_2880_posts LEFT JOIN wp_2880_term_relationships ON (wp_2880_posts.ID = wp_2880_term_relationships.object_id) WHERE 1=1 AND ( wp_2880_term_relationships.term_taxonomy_id IN (344) AND wp_2880_posts.ID NOT IN ( SELECT object_id FROM wp_2880_term_relationships WHERE term_taxonomy_id IN (620) ) ) AND wp_2880_posts.post_type = 'link_library_links' AND ((wp_2880_posts.post_status = 'publish')) GROUP BY wp_2880_posts.ID ORDER BY wp_2880_posts.post_title ASC
which is to say that they are link-library queries that are filtering by category. Looking into the plugin itself, it appears that the queries are made using WP's native query functionality, which suggests that this kind of query simply doesn't perform very well at the WordPress level, and it's not the plugin's fault. However, if this were my plugin, I would introduce some more aggressive query-level caching to ensure that these category searches don't need to be re-run at each page load.
As a workaround, I've activated a plugin on your site called advanced-post-cache. This plugin is not shown to regular users, but we use it in various places on the Commons where we want to supplement WordPress's native cache tools with better support for post queries. In the case of the /background/ page, this appears to have a dramatic improvement on load time. There's the possibility that the plugin will have some odd side-effects, specifically related to stale caches not being properly invalidated. If you see odd behavior after creating new posts or updating existing ones, let me know and we can consider whether the plugin might be disabled.
Updated by Raffi Khatchadourian about 3 years ago
Boone Gorges wrote:
...
Can you say more about the nature of the performance issues you're seeing? In my tests, it seems like the page content takes a couple seconds longer than expected to render - does this accurately reflect what you're seeing?
Yup. I noticed it around the time the plug-in was updated. This is also around the time I made multiple "libraries." It's a couple of seconds for sure. Do you think I am splitting hairs here?
I've got some query monitoring tools in place to detect potential issues, and I can see that (a) the page in question generates a lot of uncached database queries, and (b) some of those queries are pretty slow. The slowness is generally on the order of ~0.1s, but when there's a couple dozen queries of this form, the page generation time gets to be quite long. The queries have the general form:
[...]
which is to say that they are link-library queries that are filtering by category.
There should only be one category that is being filtered out (I just added this today as a workaround for a bug; there was a performance problem beforehand as well). The filtering is really by library (you can have multiple link "libraries").
Looking into the plugin itself, it appears that the queries are made using WP's native query functionality, which suggests that this kind of query simply doesn't perform very well at the WordPress level, and it's not the plugin's fault. However, if this were my plugin, I would introduce some more aggressive query-level caching to ensure that these category searches don't need to be re-run at each page load.
Understood.
As a workaround, I've activated a plugin on your site called advanced-post-cache. This plugin is not shown to regular users, but we use it in various places on the Commons where we want to supplement WordPress's native cache tools with better support for post queries. In the case of the /background/ page, this appears to have a dramatic improvement on load time. There's the possibility that the plugin will have some odd side-effects, specifically related to stale caches not being properly invalidated. If you see odd behavior after creating new posts or updating existing ones, let me know and we can consider whether the plugin might be disabled.
Thanks, but things are all messed up now :). Would you mind disabling it? Thanks for trying!
Updated by Boone Gorges about 3 years ago
Sure thing. I've disabled advanced-post-cache.
Updated by Raffi Khatchadourian about 3 years ago
Thanks, Boone. I guess I'll have to live with the delay :).
Updated by Boone Gorges about 3 years ago
- Status changed from Reporter Feedback to Rejected
- Target version set to Not tracked
Thanks, Raffi!