jeblad created this task.
jeblad added a project: MediaWiki-extensions-WikibaseClient.
Restricted Application added subscribers: Danmichaelo, Aklapper.
Restricted Application added a project: Wikidata.

TASK DESCRIPTION

The user Dipsacus_fullonum noticed and made a quick fix for mw.wikibase.getEntity() in w:no:Modul:External links.

Not discussing the merits of the module, this function is awfully slow even if it is cached. Some numbers from the thread at Moduldiskusjon:External links#Funktionen mw.wikibase.getEntity er meget langsom. The numbers are from checks run in the console

timing=require 'Module:Timing'
=timing.count(1)
=timing.sets(1)
=timing(mw.wikibase.getEntity, 'Q28614')
=timing(mw.wikibase.getEntity, 'Q28614')

First timing check gives

Each call was running for about 8.3e-02 seconds.
	Mean runtime for each set was 8.3e-02 seconds,
	with standard deviation of 0.0e+00 seconds,
	minimum 0.0e+00, maximum 0.0e+00.
	Total time spent was about 8.3e-02 seconds.
Relative load is estimated to inf.
Second timing check gives
Each call was running for about 1.0e-02 seconds.
	Mean runtime for each set was 1.0e-02 seconds,
	with standard deviation of 0.0e+00 seconds,
	minimum 0.0e+00, maximum 0.0e+00.
	Total time spent was about 1.0e-02 seconds.
Relative load is estimated to inf.

A new run for 100 calls after reload

timing=require 'Module:Timing'
=timing.count(10)
=timing.sets(10)
=timing(mw.wikibase.getEntity, 'Q28614')

Gives

Each call was running for about 1.1e-02 seconds.
	Mean runtime for each set was 1.1e-01 seconds,
	with standard deviation of 2.5e-02 seconds,
	minimum 0.0e+00, maximum 2.0e-05.
	Total time spent was about 1.1e+00 seconds.
Relative load is estimated to 57,461.0.

That is bad as it implies the cached version runs in about 10ms while the uncached runs in about 80ms. Something in the code does it wrong, as this should be close to 1ms or better way below. Ideally this is just an intercept on a call and returning a reference to the previously loaded instance.

(Without checking this, I somehow remember the code is creating a deep copy. It should probably create a non-mutable object. It is slightly harder to work with this kind of objects, but it would make it possible to return a simple reference instead of a copy. To make it possible to get a copy a second argument could be used.)


TASK DETAIL
https://phabricator.wikimedia.org/T203357

EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: jeblad
Cc: Aklapper, Danmichaelo, jeblad, Lahi, Gq86, GoranSMilovanovic, QZanden, LawExplorer, Wikidata-bugs, aude, Mbch331
_______________________________________________
Wikidata-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to