Page MenuHomePhabricator

Cache ApiQuery->makeGeneratorList so it doesn't autoload all query classes on every request
Closed, ResolvedPublic

Description

profiler image

This check for 'is a generator' is quite expensive for ApiQuery - as it has to load all class files to resolve it:

private function makeGeneratorList( $moduleList ) {

		foreach( $moduleList as  $moduleName => $moduleClass ) {
			if ( is_subclass_of( $moduleClass, 'ApiQueryGeneratorBase'  ) ) {

It may make sense to build generator list in somewhat lighter way.

This is ends up being 30%+ of API setup cost for simple API queries, e.g. api.php?action=query&format=txt

Attaching profiler image.


Version: 1.20.x
Severity: minor

Attached:

makeGeneratorList.png (1×2 px, 105 KB)

Details

Reference
bz39665

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 1:10 AM
bzimport set Reference to bz39665.
bzimport added a subscriber: Unknown Object (MLST).

Yay, reflection. Done like this, it's always going to be costly

This is at least somewhat better than it was (changed recently), in some cases, where this list would be created twice...

We stick this in some apc (maybe the simplest way), or memcached, though that feels slightly strange

Other than that, I suppose we could have this defined in code, rather than the current resultant iteration over $wgAPIPropModules and $wgAPIListModules

(In reply to comment #1)

We stick this in some apc (maybe the simplest way), or memcached, though that
feels slightly strange

Though, it would need to vary on dbname, due to various different extensions being enabled on different wikis...

Also, removing the reflection inference is a bit of a "breaking change", requiring extension authors to update their extensions where necessary.,

introducing reflection inference is already a breaking change :-)

(In reply to comment #3)

introducing reflection inference is already a breaking change :-)

It's not new, just has been refactored...