Last modified: 2010-05-15 15:33:19 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 1686 - Image metadata cache is needed to avoid multiple file operation
Image metadata cache is needed to avoid multiple file operation
Product: MediaWiki
Classification: Unclassified
File management (Other open bugs)
All All
: Normal enhancement with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch
Depends on:
  Show dependency treegraph
Reported: 2005-03-11 06:59 UTC by Andrius Ramanauskas
Modified: 2010-05-15 15:33 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---

Changes in Image.php and SpecialUpload.php files (3.25 KB, patch)
2005-03-11 07:03 UTC, Andrius Ramanauskas
A better fix (8.87 KB, patch)
2005-03-11 11:15 UTC, Andrius Ramanauskas
Fix merged into 1.4 branch (9.23 KB, patch)
2005-03-17 16:43 UTC, Andrius Ramanauskas

Description Andrius Ramanauskas 2005-03-11 06:59:55 UTC
Currently image metadata is retrieved every time image apears on the page, so
file operations (file_exists, getimagesize) are called too often.
Image metadata cache can hold this information and reuse it every time when needed.
Comment 1 Andrius Ramanauskas 2005-03-11 07:03:07 UTC
Created attachment 364 [details]
Changes in Image.php and SpecialUpload.php files

Changes in Image.php sets metadata to cache on first use an retrieves on next
Changes in SpecialUpload.php deletes metadata on image upload
Comment 2 Brion Vibber 2005-03-11 08:01:21 UTC
We'll want to move metadata into the image tables for 1.5, but 
this might be a helpful hack for 1.4 for the meantime. A few 

If you can post diffs in -u format that'd be helpful; these are more 
legible (including context) and are easier to apply to modified 

Use tabs for indentation to keep consistency with existing code.

Memcached has a key length limit of 255 bytes; we have a title 
limit of 255 bytes. A long image name thus may not fit; consider 
using a hashed name in the key.

It might be best to explicitly support the shared image source 
directory (commons); for instance by checking two memcached 
keys (shared and local).

Does this interact correctly with generated thumbnails? What 
about image deletions and reversions?

Remember to remove your test 'echo's before submitting patches. 

The [$i++] stuff is somewhat opaque; consider using a dictionary. 
($cachedValues = array( 'name' => $this->name, ... )
Comment 3 Andrius Ramanauskas 2005-03-11 11:15:45 UTC
Created attachment 365 [details]
A better fix

Removed echos (shame for me for leaving those :), tabified, implemented cache
invalidation on delete/undelete/revert, better support of commons
Comment 4 Andrius Ramanauskas 2005-03-11 11:24:26 UTC
(In reply to comment #2)
> <..>
> Does this interact correctly with generated thumbnails? What 
> about image deletions and reversions?
> <..>

It does show thumbnails correctly, so I guess that it should not impact them
anyway (except that original image is not accessed for metadata retrieving).
However, there are few file_exists calls for thumbnails, but I'm not sure I know
enough about thumbnail lifetime to add some caching here.
Comment 5 Tim Starling 2005-03-13 15:05:44 UTC
This is committed to HEAD, it really should be backported to REL1_4. The
severity of this bug is "enhancement" but actually it's the major performance
problem in Wikipedia at the moment, apparently causing frequent timeouts. 
Comment 6 Zigger 2005-03-13 16:41:44 UTC
(In reply to comment #5)
Set Version & Keywords accordingly.

Comment 7 Andrius Ramanauskas 2005-03-17 16:43:36 UTC
Created attachment 369 [details]
Fix merged into 1.4 branch

Merger same fix (with Tim's adjustments) into 1.4 branch
Comment 8 Antoine "hashar" Musso (WMF) 2005-03-27 19:42:50 UTC

Note You need to log in before you can comment on or make changes to this bug.