Page MenuHomePhabricator

DiscussionTools is making duplicate DB requests back to back
Closed, ResolvedPublic

Description

I'm checking queries made by a purge and I saw this:

image.png (436×1 px, 119 KB)

It needs to have some cache.
Here is the call graph and call count for that code in DiscussionTools: https://performance.wikimedia.org/xhgui/run/symbol?id=61ae46afebb32a41e58d4f13&symbol=MediaWiki%5CExtension%5CDiscussionTools%5CHooks%5CHookUtils%3A%3AisAvailableForTitle

Fixing this would remove something on 1k query/sec at least. Let me know if you have reproducing the problem

Event Timeline

Change 744889 had a related patch set uploaded (by Esanders; author: Esanders):

[mediawiki/extensions/DiscussionTools@master] Cache page properties in memory to avoid extra queries

https://gerrit.wikimedia.org/r/744889

On my local test page this fix results in DT making 8 queries instead of 22. Thanks.

Change 744889 merged by jenkins-bot:

[mediawiki/extensions/DiscussionTools@master] Cache page properties in memory to avoid extra queries

https://gerrit.wikimedia.org/r/744889

I think this is actually a bug in the core PageProps class, which we are using. In PageProps::getProperties(), there's a ton of code that does caching, but only when the property is set – nothing is cached if the property we're querying for isn't present on the page. This seems unexpected to me.

I think this is actually a bug in the core PageProps class, which we are using. In PageProps::getProperties(), there's a ton of code that does caching, but only when the property is set – nothing is cached if the property we're querying for isn't present on the page. This seems unexpected to me.

Thanks for fixing it quickly. if you want to make a patch against that in core, I'd be more than happy to review it. I think the general attitude of core's caching is that if the value is falsy, it doesn't cache them. e.g. getWithSetCallback doesn't cache if the callback returns false. This was not my idea and I don't even like these implicit logic bits but it is the current situation.

ppelberg claimed this task.

Change 746920 had a related patch set uploaded (by Ladsgroup; author: Esanders):

[mediawiki/extensions/DiscussionTools@wmf/1.38.0-wmf.12] Cache page properties in memory to avoid extra queries

https://gerrit.wikimedia.org/r/746920

Change 746920 merged by jenkins-bot:

[mediawiki/extensions/DiscussionTools@wmf/1.38.0-wmf.12] Cache page properties in memory to avoid extra queries

https://gerrit.wikimedia.org/r/746920

Mentioned in SAL (#wikimedia-operations) [2021-12-14T05:09:05Z] <ladsgroup@deploy1002> Synchronized php-1.38.0-wmf.12/extensions/DiscussionTools/includes/Hooks/HookUtils.php: Backport: [[gerrit:746920|Cache page properties in memory to avoid extra queries (T297132 T297669)]] (duration: 00m 57s)