Database query performance isn't the leading performance bottleneck on the WMF cluster. If reading or writing to a database, certainly do take the time to specifically profile your database queries, and make sure to efficiently use caching (and avoid stampede scenarios on cache expiration) whenever possible. Hopefully in the future, caching won't be as up to individual developers to get right on an ad hoc basis. In the last year, we made changes that reduced the query load to mysql masters by nearly 70%. Those queries were well written - there was nothing to tune at the sql layer. The point being, query tuning can't substitute for or even correlate to making efficient design decisions.
If you have profiled sql queries, or if your code doesn't have any to profile, don't stop there. Profiling the code itself is at least as important. The mediawiki profiler ( https://www.mediawiki.org/wiki/Profiler#Profiling) offers an easy place to start and it's good to include profiling hooks as they automatically result in p90/p99, etc. latency graphs in graphite in production. But for individual development environments, setting up xhprof might be more useful. There are plenty of tutorials out there, such as - http://blog.cnizz.com/2012/05/05/enhanced-php-performance-profiling-with-xhp...
Ori - I think this has been discussed but automated xhprof configuration as part of the vagrant dev env setup would be amazing :)
On Wed, Mar 6, 2013 at 4:36 PM, Sumana Harihareswara sumanah@wikimedia.orgwrote:
If you want your code merged, you need to keep your database queries efficient. How can you tell if a query is inefficient? How do you write efficient queries, and avoid inefficient ones? We have some resources around:
Roan Kattouw's
https://www.mediawiki.org/wiki/Manual:Database_layout/MySQL_Optimization/Tut... -- slides at https://commons.wikimedia.org/wiki/File:MediaWikiPerformanceProfiling.pdf
Roan's slides actually at https://www.mediawiki.org/wiki/File:SQL_indexing_Tutorial.pdf
But! If you're a developer and would appreciate guidance around how to best create and efficiently use indexes, I highly recommend this slide deck: http://www.percona.com/files/presentations/WEBINAR-tools-and-techniques-for-...
Asher Feldman's https://www.mediawiki.org/wiki/File:MediaWiki_Performance_Profiling.ogv -- slides at https://www.mediawiki.org/wiki/File:SQL_indexing_Tutorial.pdf
slides actually at https://commons.wikimedia.org/wiki/File:MediaWikiPerformanceProfiling.pdf
More hints: http://lists.wikimedia.org/pipermail/toolserver-l/2012-June/005075.html
Due to the use of views on toolserver, it isn't really possible to use that environment to profile or tune queries as they would actually run in production.
When you need to ask for a performance review, you can check out https://www.mediawiki.org/wiki/Developers/Maintainers#Other_Areas_of_Focus which suggests Tim Starling, Asher Feldman, and Ori Livneh. I also BOLDly suggest Nischay Nahata, who worked on Semantic MediaWiki's performance for his GSoC project in 2012.
-- Sumana Harihareswara Engineering Community Manager Wikimedia Foundation
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l