Last active
October 11, 2017 10:28
-
-
Save macbre/58039dff564573b620dab835f41a20fd to your computer and use it in GitHub Desktop.
MySQL 5.6 vs 5.7 performance comparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
env/ | |
*.swp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c1 | c2 | c3 | c4 | c5 | c6 | c7 | ||
---|---|---|---|---|---|---|---|---|
Median query time | 0.2529 | 0.2622 | 0.3326 | 0.3822 | 0.3282 | 0.2625 | 0.3983 | |
Queries count | 6868407 | 5220013 | 4491414 | 4400304 | 2150254 | 2790681 | 3465137 | |
QPS | 7949.55 | 6041.68 | 5198.40 | 5092.94 | 2488.72 | 3229.95 | 4010.58 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import logging | |
from collections import OrderedDict, defaultdict | |
from wikia.common.kibana import Kibana | |
PERIOD=24*3600 # get query for the last 24 hours | |
STATS_FIELD='50.0' # report 50th percentile | |
# set up logging | |
logging.basicConfig( | |
level=logging.INFO, | |
format='%(asctime)s %(name)-35s %(levelname)-8s %(message)s', | |
datefmt="%Y-%m-%d %H:%M:%S" | |
) | |
def get_query_perf_from_cluster(cluster): | |
stats = Kibana(period=PERIOD, index_prefix='logstash-mediawiki').get_aggregations( | |
query='appname: "mediawiki" AND @fields.datacenter: "sjc" AND @fields.environment: "prod" ' + \ | |
'AND @message: "SQL" AND NOT @message: "action=delete" AND @context.cluster: "{}"'.format(cluster), | |
group_by='@context.method.keyword', | |
stats_field='@context.elapsed' | |
) | |
# print(stats) | |
return stats | |
def main(): | |
logger = logging.getLogger('mysql_perf') | |
clusters = map(lambda i: 'c' + str(i), xrange(1,8)) | |
logger.info("Checking clusters: {}".format(clusters)) | |
# collect per-cluster stats | |
cluster_stats = OrderedDict() | |
for cluster in clusters: | |
cluster_stats[cluster] = get_query_perf_from_cluster(cluster) | |
# now compose per-method stats grouped by cluster | |
per_method_stats = defaultdict(dict) | |
methods = cluster_stats[clusters[0]].keys() | |
for method in methods: | |
for cluster in clusters: | |
per_method_stats[method][cluster] = cluster_stats[cluster].get(method) | |
logger.info("Generating CSV...") | |
# now write CSV | |
with open('perf.csv', 'w') as csvfile: | |
writer = csv.writer(csvfile, delimiter=',') | |
writer.writerow(['Method'] + clusters) | |
for method in sorted(per_method_stats.keys()): | |
row = [method] | |
# per-cluster stats for a given method | |
stats = per_method_stats[method] | |
for cluster in clusters: | |
if stats[cluster] is not None: | |
row.append('{:.4f}'.format( | |
1000.0 * stats[cluster].get(STATS_FIELD) # [ms] | |
)) | |
else: | |
row.append('-') | |
writer.writerow(row) | |
logger.info("Done") | |
# import json; print(json.dumps(per_method_stats, indent=True)) | |
if __name__ == "__main__": | |
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import logging | |
from wikia.common.kibana import Kibana | |
PERIOD=24*3600 # get query for the last 24 hours | |
# set up logging | |
logging.basicConfig( | |
level=logging.INFO, | |
format='%(asctime)s %(name)-35s %(levelname)-8s %(message)s', | |
datefmt="%Y-%m-%d %H:%M:%S" | |
) | |
def main(): | |
stats = Kibana(period=PERIOD, index_prefix='logstash-mediawiki').get_aggregations( | |
query='appname: "mediawiki" AND @fields.datacenter: "sjc" AND @fields.environment: "prod" ' + \ | |
'AND @message: "SQL" AND NOT @message: "action=delete" AND @context.cluster: *', | |
group_by='@context.cluster.keyword', | |
stats_field='@context.elapsed' | |
) | |
clusters = sorted(stats.keys()) | |
with open('clusters.csv', 'w') as csvfile: | |
writer = csv.writer(csvfile, delimiter=',') | |
writer.writerow([''] + clusters) | |
writer.writerow(['Median query time'] + ['{:.4f}'.format(1000.0 * stats[cluster].get('50.0')) for cluster in clusters]) | |
writer.writerow(['Queries count'] + [stats[cluster].get('count') for cluster in clusters]) | |
writer.writerow(['QPS'] + ['{:.2f}'.format(100.0 * stats[cluster].get('count') / PERIOD) for cluster in clusters]) # x100 - we log SQL queries with 1% sampling | |
if __name__ == "__main__": | |
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Method | c1 | c2 | c3 | c4 | c5 | c6 | c7 | |
---|---|---|---|---|---|---|---|---|
ApiPageSet::initFromPageIds | 0.2301 | 0.2160 | - | 0.3637 | - | - | - | |
ApiPageSet::initFromTitles | 0.2620 | 0.2528 | 0.3486 | 0.4028 | 0.3141 | 0.2687 | 0.4081 | |
ApiQueryLogEvents::execute | 0.7519 | 0.6951 | - | 0.7078 | - | - | 0.7029 | |
ApiQueryRecentChanges::run | 0.6174 | 0.5908 | 0.8154 | 0.6520 | 0.6163 | 0.5404 | 0.6679 | |
ApiQueryRevisions::execute | 0.5514 | 0.4119 | - | 0.5827 | - | 0.4111 | 0.6310 | |
ArticleComment::getFirstRevID | 0.1851 | 0.1965 | 0.2690 | 0.3208 | 0.2596 | 0.1910 | 0.3198 | |
ArticleCommentList::getCommentList | 0.3723 | 0.4111 | 0.4211 | 0.4398 | 0.3633 | 0.3140 | 0.4232 | |
ArticlesUsingMediaQuery::getArticleList | 0.3953 | 0.3702 | 0.4462 | 0.4977 | 0.4139 | 0.3357 | 0.5285 | |
Block::newLoad | 0.4499 | 0.4221 | 0.4999 | 0.5411 | 0.4672 | 0.4112 | 0.6047 | |
CategoriesService::getHiddenCategories | 2.0672 | 4.7496 | 0.7951 | 0.5850 | - | 0.4302 | 0.4951 | |
Category::initialize | 0.2383 | 0.2475 | 0.3310 | 0.3716 | 0.3088 | 0.2401 | 0.3743 | |
CategoryDataService::getAlphabetical | 0.3888 | 0.3559 | 0.4589 | 0.4941 | 0.3983 | 0.3398 | 0.4654 | |
CategoryDataService::getMostVisited | 0.6087 | 0.5220 | 0.5583 | 0.5894 | 0.4479 | 0.3973 | 0.5214 | |
CategoryExhibitionSectionMedia::getLinkedFiles | 0.2652 | 0.2837 | 0.3599 | 0.4127 | 0.3304 | - | - | |
CategoryPaginationViewer::processSection | 0.3783 | 0.3680 | 0.4541 | 0.4964 | 0.4290 | 0.3828 | 0.5355 | |
CategoryViewer::doCategoryQuery | 0.6503 | 0.6849 | 0.7434 | 0.6856 | 0.5830 | 0.5547 | - | |
CommentsIndex::entryFromId | 0.2468 | 0.2610 | 0.3357 | 0.3990 | 0.3247 | 0.2533 | 0.4033 | |
DPLMain:dynamicPageList | 0.2395 | 0.3780 | - | - | - | - | - | |
DataMartService:doGetTopArticlesByPageview | 0.4835 | 0.4483 | 0.4389 | 0.4445 | 0.4456 | 0.4398 | 0.3752 | |
DataMartService:getPageviews | 0.6059 | - | - | - | - | - | - | |
DatabaseBase::query (Block::newLoad) | 0.0911 | - | - | - | - | - | - | |
DatabaseBase::query (ExternalUser_Wikia::linkToLocal) | 0.0911 | 0.0950 | 0.2167 | 0.0895 | 0.2226 | 0.1800 | 0.1559 | |
DatabaseBase::query (wfGetWikiaNewtalk) | 0.0880 | 0.0880 | 0.0880 | 0.0880 | 0.0880 | 0.0883 | 0.0880 | |
DatabaseBase::select | 0.1922 | 0.1896 | 0.2751 | - | 0.2620 | - | - | |
DatabaseBase::selectField | 0.1603 | 0.1763 | 0.2355 | 0.2766 | 0.2239 | 0.1788 | 0.2853 | |
DatabaseMysqlBase::getLagFromSlaveStatus | 0.2724 | 0.2660 | 0.2930 | 0.3139 | 0.3015 | 0.2837 | 0.3148 | |
DatabaseMysqlBase::open | 0.0961 | - | - | - | 0.0970 | - | - | |
DatabaseMysqlBase::setBigSelects | 0.1168 | 0.1030 | 0.1973 | 0.2380 | 0.1871 | 0.1431 | 0.2420 | |
ExternalStoreDB::fetchBlob | 0.2489 | 0.2696 | 0.2585 | 0.2560 | 0.2392 | 0.2448 | 0.2369 | |
ExternalUser_Wikia::initFromCond | 0.2432 | 0.2511 | 0.2470 | 0.2501 | 0.2531 | 0.2520 | 0.2552 | |
ExternalUser_Wikia::linkToLocal | 0.1937 | 0.2169 | 0.3198 | 0.1719 | 0.3292 | 0.2768 | 0.2510 | |
FilePageController::getGlobalUsage | 0.6181 | 0.6212 | 0.6197 | 0.6173 | 0.6235 | 0.6209 | 0.6212 | |
FilePageController::queryImageLinks | 0.4998 | 0.4386 | 0.5638 | 1.0209 | 0.5042 | 0.7674 | 0.6617 | |
GenderCache::doQuery/Skin::preloadExistence | 0.3149 | 0.2940 | 0.3900 | 0.4282 | 0.3821 | 0.3195 | 0.5170 | |
GenderCache::doQuery/Title::getNsText | 0.2600 | 0.2730 | 0.3479 | 0.3859 | 0.3274 | 0.2556 | 0.3987 | |
GlobalTitle::exists | 0.1950 | 0.1955 | 0.2810 | 0.3395 | 0.2710 | 0.2194 | 0.3465 | |
GlobalTitle::getContent | 0.2483 | 0.2583 | 0.3288 | 0.3791 | 0.3127 | 0.2614 | 0.3846 | |
GlobalTitle::getContentByTextId | 0.2220 | 0.2330 | 0.3082 | 0.3545 | 0.2816 | 0.2217 | 0.3676 | |
GlobalTitle::isRedirect | 0.2121 | 0.2117 | 0.2120 | 0.2115 | 0.2102 | 0.2057 | 0.2048 | |
ImageServing::getImages | 0.2116 | 0.2220 | 0.2937 | 0.3485 | 0.2771 | 0.2230 | 0.3570 | |
ImageServingDriverMainNS::getImageIndex | 0.3266 | 0.3110 | 0.3883 | 0.4372 | 0.3488 | 0.2906 | 0.4487 | |
ImageServingDriverMainNS::getImagesPopularity | 0.6643 | 0.5985 | 0.7290 | 0.8759 | 0.6241 | 0.6860 | 0.6541 | |
ImageServingDriverMainNS::loadImagesMetadata | 0.2943 | 0.2509 | 0.3717 | 0.4140 | 0.3416 | 0.2658 | 0.4059 | |
IndexPager::reallyDoQuery (LogPager) | 0.8424 | 0.8450 | 1.1380 | 2.1081 | 0.9171 | 1.9087 | 1.1508 | |
Interwiki::load | 0.2510 | - | - | 2.1782 | - | 1.4051 | 1.1602 | |
LinkBatch::doQuery (for Skin::preloadExistence) | 0.3410 | 0.3461 | 0.4290 | 0.4809 | 0.3879 | 0.3449 | 0.4715 | |
LinkCache::addLinkObj | 0.2221 | 0.2363 | 0.3114 | 0.3614 | 0.2974 | 0.2362 | 0.3604 | |
LinkHolderArray::replaceInternal | 0.3168 | 0.3076 | 0.3858 | 0.4351 | 0.3733 | 0.3191 | 0.4222 | |
LinkSuggest::getLinkSuggest | 5.0390 | 4.7838 | 4.0338 | 4.5737 | 4.3083 | 2.2005 | 1.2124 | |
LinksUpdate::invalidatePages | 0.1861 | 0.1961 | 0.3532 | 0.1679 | 1.8834 | 0.2388 | 0.2380 | |
LocalFile::getHistory | 0.4070 | 0.3932 | 0.5033 | 0.5419 | 0.4369 | 0.5148 | 0.6327 | |
LocalRepo::checkRedirect | 0.1828 | 0.1590 | 0.2865 | 0.3360 | 0.2721 | 0.2006 | 0.3468 | |
LocalRepo::getArticleID | 0.2110 | 0.2247 | 0.2915 | 0.3436 | 0.2784 | 0.2211 | 0.3471 | |
OutputPage::addCategoryLinks | 0.4878 | 0.4543 | 0.5383 | 0.6080 | 0.5000 | 0.4646 | 0.6231 | |
ResourceLoader::preloadModuleInfo | 0.4004 | 0.3691 | 0.4543 | 0.6032 | 0.4256 | 0.5345 | 0.5762 | |
ResourceLoaderGlobalWikiModule::reallyGetTitleMtimes | 0.2549 | 0.2369 | 0.3094 | 0.3734 | 0.3124 | 0.2708 | 0.3835 | |
ResourceLoaderWikiModule::reallyGetTitleMtimes | 0.2100 | 0.2231 | 0.2897 | 0.3446 | 0.2760 | 0.2211 | 0.3482 | |
Revision::fetchFromConds | 0.3546 | 0.3516 | 0.4266 | 0.4911 | 0.4036 | 0.3361 | 0.4835 | |
Revision::insertOn | 0.2385 | 0.2986 | 0.3502 | 0.2185 | 0.3420 | 0.3030 | 0.4966 | |
Revision::loadText | 0.4149 | 0.3069 | 0.4348 | 0.6247 | 0.3454 | 0.2370 | 0.4177 | |
SDUtils:getCategoryChildren | 0.3495 | - | - | - | - | - | - | |
SMWSQLStore3Readers::fetchSemanticData | 0.2663 | 0.3152 | 0.2731 | 0.3759 | 0.2456 | - | - | |
SMWSQLStore3Readers::getInProperties | 0.1943 | 0.1824 | 0.1951 | - | 0.1811 | - | - | |
SMWSql3SmwIds::getDatabaseIdAndSort | 0.2624 | 0.2682 | 0.2520 | 0.3726 | 0.2416 | - | - | |
SMWSql3SmwIds::getPropertyTableHashes | 0.1856 | - | - | - | - | - | - | |
SiteWideMessages::getAllUserMessages | 0.3832 | 0.3838 | 0.3838 | 0.3843 | 0.3860 | 0.3818 | 0.3761 | |
SpecialAllpages::showToplevel | 0.3296 | 0.2905 | 0.3880 | 0.4416 | 0.3781 | 0.3377 | - | |
Title::countRevisionsBetween | 0.2607 | 0.2731 | - | - | - | - | - | |
Title::getCascadeProtectionSources | 0.3898 | 0.3670 | 0.4417 | 0.4819 | 0.4010 | 0.3549 | 0.5543 | |
Title::getParentCategories | 0.4269 | 0.3105 | 0.5365 | 0.8720 | - | 0.7699 | - | |
Title::getPreviousRevisionID | 0.2619 | 0.2761 | 0.3566 | 0.4056 | - | 0.2800 | 0.4122 | |
Title::getTitleProtection | 0.3620 | 0.3190 | 0.4062 | 0.4670 | 0.3674 | 0.3413 | 0.5360 | |
Title::invalidateCache | 0.2058 | 0.2660 | 0.3288 | 0.1816 | 0.3386 | 0.2721 | 0.2403 | |
Title::isNewPage | 0.1811 | 0.1942 | 0.2653 | 0.3284 | 0.2513 | 0.1900 | 0.3351 | |
Title::loadRestrictions | 0.2822 | 0.2748 | 0.3324 | 0.3862 | 0.3181 | 0.2408 | 0.3943 | |
Title::loadRestrictionsFromRows | 0.1724 | 0.1610 | 0.2615 | 0.3272 | 0.2492 | 0.1881 | 0.3339 | |
Title::newFromID | 0.2085 | 0.2029 | 0.2996 | 0.3587 | 0.2851 | 0.2280 | 0.3705 | |
Title::newFromIDs | 0.2601 | 0.2725 | 0.4135 | 0.4350 | 0.3560 | 0.3035 | 0.4636 | |
User::checkNewtalk | 0.4574 | 0.4452 | 0.7369 | 1.7188 | 0.4804 | 1.2681 | 0.7923 | |
User::idFromName | 0.2050 | 0.2111 | 0.2499 | 0.3190 | 0.2429 | 0.2071 | 0.3220 | |
User::loadFromDatabase | 0.2279 | 0.2303 | 0.2328 | 0.2314 | 0.2310 | 0.2318 | 0.2318 | |
User::loadOptions | 0.2695 | 0.2753 | 0.2798 | 0.2791 | 0.2854 | 0.2966 | 0.3173 | |
WallNotifications::remNotificationsForUniqueIDDB | 0.2480 | - | 0.2563 | 0.2485 | - | 0.2256 | 0.2479 | |
WallRelatedPages::getArticlesRelatedMessgesIds | 0.6846 | - | 0.7583 | 1.6423 | - | 0.6188 | 0.8262 | |
WatchedItem::isWatched | 0.2198 | 0.2514 | 0.3136 | 0.3648 | 0.2949 | 0.2384 | 0.3820 | |
WikiFactory::DomainToID | 0.1920 | - | - | - | - | - | - | |
WikiFactory::getCategories | 0.2568 | 0.2563 | 0.2560 | 0.2576 | 0.2551 | 0.2543 | 0.2496 | |
WikiFactory::getWikiByDB | 0.3267 | - | - | - | - | - | - | |
WikiFactory::getWikiByID | 0.2987 | - | 0.3080 | 0.3060 | 0.3045 | 0.3065 | 0.3096 | |
WikiPage::getRedirectTarget | 0.1947 | 0.1988 | 0.2899 | 0.3396 | 0.2691 | 0.2015 | 0.3434 | |
WikiPage::insertOn | 0.2276 | 0.3325 | 0.3918 | 0.2152 | 0.3886 | 0.3369 | 0.8980 | |
WikiPage::pageData | 0.2958 | 0.2910 | 0.3919 | 0.4317 | 0.3687 | 0.3064 | 0.4525 | |
WikiPage::updateRevisionOn | 0.2494 | 0.3624 | 0.3960 | 0.2246 | 0.3907 | 0.3427 | 0.3748 | |
Wikia::getProps | 0.2162 | 0.2349 | 0.3011 | 0.3580 | 0.2825 | 0.2291 | 0.3701 | |
WikiaLocalFile::loadFromDB | 0.2723 | 0.2851 | 0.3701 | 0.4213 | 0.3414 | 0.2758 | 0.4290 | |
WikiaNewFilesModel:addLinkingArticles | 0.2728 | 0.2881 | 0.3719 | 0.4291 | - | 0.2867 | 0.4301 | |
Wikia\ContentReview\Models\CurrentRevisionModel:getLatestReviewedRevision | 0.2359 | - | - | - | 0.2307 | - | - | |
getMenuHelper | 0.6684 | 0.5081 | 0.4697 | 0.3864 | 0.2923 | 0.2242 | 0.3843 | |
wfGetWikiaNewtalk | 0.1916 | 0.1936 | 0.1929 | 0.1929 | 0.1921 | 0.1930 | 0.1941 | |
wfGetWikiaPageProp | 0.2569 | 0.2507 | 0.3272 | 0.3851 | 0.3054 | 0.2352 | 0.3783 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wikia-common-kibana==2.2.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment