Page MenuHomePhabricator

Maps with SPARQL queries should count as expensive parser functions
Closed, InvalidPublic

Description

Nothing in Maps (Kartographer) is counted as part of $wgExpensiveParserFunctionLimit, i.e. Parser::incrementExpensiveFunctionCount() is never called. We probably should do this in some cases:

  • When there is a SPARQL "query": "…" in the GeoJSON. These call the Wikidata query service and can be arbitrarily expensive.
  • When using "service": "geopoint" together with "ids": "Q42" what we really do is running a SPARQL query. It's a very cheap one. Still it calls the Wikidata Query service, so should probably be counted as well?
  • Pulling a .map file from Commons is almost like including an image. That's not expensive.

A recent example where we started counting an existing feature as expensive is T316858: A page with an extreme amount of <syntaxhighlight> tags hits the RequestTimeout when trying to render. The main argument there was also that an external service (in that case a Python script) is called.

Event Timeline

Change 838759 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Kartographer@master] [POC] Count maps with SPARQL queries as expensive

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

I think the calls you're looking at are actually made at page view time, not at parse time.

Still they are expensive, and a page with thousands of them should probably not exist. But yes, this is technically implemented in the wrong place. All that really happens on parse time is that a URL that contains the SPARQL query is generated. Suggestions?

We also talked about potentially querying the Wikidata query service on parse time. It will definitely be an expensive parser function then.

I like the suggestion to mark these as expensive if we decide to push ExternalData rendering into initial page parse.

Change 838759 abandoned by Thiemo Kreuz (WMDE):

[mediawiki/extensions/Kartographer@master] [POC] Count maps with SPARQL queries as expensive

Reason:

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