Index: branches/REL1_18/phase3/includes/Wiki.php |
— | — | @@ -419,7 +419,6 @@ |
420 | 420 | * Ends this task peacefully |
421 | 421 | */ |
422 | 422 | public function restInPeace() { |
423 | | - MessageCache::logMessages(); |
424 | 423 | wfLogProfilingData(); |
425 | 424 | // Commit and close up! |
426 | 425 | $factory = wfGetLBFactory(); |
Index: branches/REL1_18/phase3/includes/cache/MessageCache.php |
— | — | @@ -43,26 +43,6 @@ |
44 | 44 | protected $mLoadedLanguages = array(); |
45 | 45 | |
46 | 46 | /** |
47 | | - * Used for automatic detection of most used messages. |
48 | | - */ |
49 | | - protected $mRequestedMessages = array(); |
50 | | - |
51 | | - /** |
52 | | - * How long the message request counts are stored. Longer period gives |
53 | | - * better sample, but also takes longer to adapt changes. The counts |
54 | | - * are aggregrated per day, regardless of the value of this variable. |
55 | | - */ |
56 | | - protected static $mAdaptiveDataAge = 604800; // Is 7*24*3600 |
57 | | - |
58 | | - /** |
59 | | - * Filter the tail of less used messages that are requested more seldom |
60 | | - * than this factor times the number of request of most requested message. |
61 | | - * These messages are not loaded in the default set, but are still cached |
62 | | - * individually on demand with the normal cache expiry time. |
63 | | - */ |
64 | | - protected static $mAdaptiveInclusionThreshold = 0.05; |
65 | | - |
66 | | - /** |
67 | 47 | * Singleton instance |
68 | 48 | * |
69 | 49 | * @var MessageCache |
— | — | @@ -369,12 +349,12 @@ |
370 | 350 | * $wgMaxMsgCacheEntrySize are assigned a special value, and are loaded |
371 | 351 | * on-demand from the database later. |
372 | 352 | * |
373 | | - * @param $code String: language code. |
374 | | - * @return Array: loaded messages for storing in caches. |
| 353 | + * @param $code Optional language code, see documenation of load(). |
| 354 | + * @return Array: Loaded messages for storing in caches. |
375 | 355 | */ |
376 | | - function loadFromDB( $code ) { |
| 356 | + function loadFromDB( $code = false ) { |
377 | 357 | wfProfileIn( __METHOD__ ); |
378 | | - global $wgMaxMsgCacheEntrySize, $wgLanguageCode, $wgAdaptiveMessageCache; |
| 358 | + global $wgMaxMsgCacheEntrySize, $wgLanguageCode; |
379 | 359 | $dbr = wfGetDB( DB_SLAVE ); |
380 | 360 | $cache = array(); |
381 | 361 | |
— | — | @@ -384,26 +364,19 @@ |
385 | 365 | 'page_namespace' => NS_MEDIAWIKI, |
386 | 366 | ); |
387 | 367 | |
388 | | - $mostused = array(); |
389 | | - if ( $wgAdaptiveMessageCache ) { |
390 | | - $mostused = $this->getMostUsedMessages(); |
| 368 | + if ( $code ) { |
| 369 | + # Is this fast enough. Should not matter if the filtering is done in the |
| 370 | + # database or in code. |
391 | 371 | if ( $code !== $wgLanguageCode ) { |
392 | | - foreach ( $mostused as $key => $value ) { |
393 | | - $mostused[$key] = "$value/$code"; |
394 | | - } |
| 372 | + # Messages for particular language |
| 373 | + $conds[] = 'page_title' . $dbr->buildLike( $dbr->anyString(), "/$code" ); |
| 374 | + } else { |
| 375 | + # Effectively disallows use of '/' character in NS_MEDIAWIKI for uses |
| 376 | + # other than language code. |
| 377 | + $conds[] = 'page_title NOT' . $dbr->buildLike( $dbr->anyString(), '/', $dbr->anyString() ); |
395 | 378 | } |
396 | 379 | } |
397 | 380 | |
398 | | - if ( count( $mostused ) ) { |
399 | | - $conds['page_title'] = $mostused; |
400 | | - } elseif ( $code !== $wgLanguageCode ) { |
401 | | - $conds[] = 'page_title' . $dbr->buildLike( $dbr->anyString(), "/$code" ); |
402 | | - } else { |
403 | | - # Effectively disallows use of '/' character in NS_MEDIAWIKI for uses |
404 | | - # other than language code. |
405 | | - $conds[] = 'page_title NOT' . $dbr->buildLike( $dbr->anyString(), '/', $dbr->anyString() ); |
406 | | - } |
407 | | - |
408 | 381 | # Conditions to fetch oversized pages to ignore them |
409 | 382 | $bigConds = $conds; |
410 | 383 | $bigConds[] = 'page_len > ' . intval( $wgMaxMsgCacheEntrySize ); |
— | — | @@ -431,12 +404,6 @@ |
432 | 405 | $cache[$row->page_title] = ' ' . Revision::getRevisionText( $row ); |
433 | 406 | } |
434 | 407 | |
435 | | - foreach ( $mostused as $key ) { |
436 | | - if ( !isset( $cache[$key] ) ) { |
437 | | - $cache[$key] = '!NONEXISTENT'; |
438 | | - } |
439 | | - } |
440 | | - |
441 | 408 | $cache['VERSION'] = MSG_CACHE_VERSION; |
442 | 409 | wfProfileOut( __METHOD__ ); |
443 | 410 | return $cache; |
— | — | @@ -608,13 +575,6 @@ |
609 | 576 | $uckey = $wgContLang->ucfirst( $lckey ); |
610 | 577 | } |
611 | 578 | |
612 | | - /** |
613 | | - * Record each message request, but only once per request. |
614 | | - * This information is not used unless $wgAdaptiveMessageCache |
615 | | - * is enabled. |
616 | | - */ |
617 | | - $this->mRequestedMessages[$uckey] = true; |
618 | | - |
619 | 579 | # Try the MediaWiki namespace |
620 | 580 | if( !$this->mDisable && $useDB ) { |
621 | 581 | $title = $uckey; |
— | — | @@ -679,7 +639,8 @@ |
680 | 640 | * @param $code String: code denoting the language to try. |
681 | 641 | */ |
682 | 642 | function getMsgFromNamespace( $title, $code ) { |
683 | | - global $wgAdaptiveMessageCache; |
| 643 | + $type = false; |
| 644 | + $message = false; |
684 | 645 | |
685 | 646 | $this->load( $code ); |
686 | 647 | if ( isset( $this->mCache[$code][$title] ) ) { |
— | — | @@ -688,26 +649,13 @@ |
689 | 650 | return substr( $entry, 1 ); |
690 | 651 | } elseif ( $entry === '!NONEXISTENT' ) { |
691 | 652 | return false; |
692 | | - } elseif( $entry === '!TOO BIG' ) { |
693 | | - // Fall through and try invididual message cache below |
694 | 653 | } |
695 | | - } else { |
696 | | - // XXX: This is not cached in process cache, should it? |
697 | | - $message = false; |
698 | | - wfRunHooks( 'MessagesPreLoad', array( $title, &$message ) ); |
699 | | - if ( $message !== false ) { |
700 | | - return $message; |
701 | | - } |
| 654 | + } |
702 | 655 | |
703 | | - /** |
704 | | - * If message cache is in normal mode, it is guaranteed |
705 | | - * (except bugs) that there is always entry (or placeholder) |
706 | | - * in the cache if message exists. Thus we can do minor |
707 | | - * performance improvement and return false early. |
708 | | - */ |
709 | | - if ( !$wgAdaptiveMessageCache ) { |
710 | | - return false; |
711 | | - } |
| 656 | + # Call message hooks, in case they are defined |
| 657 | + wfRunHooks('MessagesPreLoad', array( $title, &$message ) ); |
| 658 | + if ( $message !== false ) { |
| 659 | + return $message; |
712 | 660 | } |
713 | 661 | |
714 | 662 | # Try the individual message cache |
— | — | @@ -733,7 +681,6 @@ |
734 | 682 | $this->mCache[$code][$title] = ' ' . $message; |
735 | 683 | $this->mMemc->set( $titleKey, ' ' . $message, $this->mExpiry ); |
736 | 684 | } else { |
737 | | - $message = false; |
738 | 685 | $this->mCache[$code][$title] = '!NONEXISTENT'; |
739 | 686 | $this->mMemc->set( $titleKey, '!NONEXISTENT', $this->mExpiry ); |
740 | 687 | } |
— | — | @@ -868,77 +815,4 @@ |
869 | 816 | return array( $message, $lang ); |
870 | 817 | } |
871 | 818 | |
872 | | - public static function logMessages() { |
873 | | - wfProfileIn( __METHOD__ ); |
874 | | - global $wgAdaptiveMessageCache; |
875 | | - if ( !$wgAdaptiveMessageCache || !self::$instance instanceof MessageCache ) { |
876 | | - wfProfileOut( __METHOD__ ); |
877 | | - return; |
878 | | - } |
879 | | - |
880 | | - $cachekey = wfMemckey( 'message-profiling' ); |
881 | | - $cache = wfGetCache( CACHE_DB ); |
882 | | - $data = $cache->get( $cachekey ); |
883 | | - |
884 | | - if ( !$data ) { |
885 | | - $data = array(); |
886 | | - } |
887 | | - |
888 | | - $age = self::$mAdaptiveDataAge; |
889 | | - $filterDate = substr( wfTimestamp( TS_MW, time() - $age ), 0, 8 ); |
890 | | - foreach ( array_keys( $data ) as $key ) { |
891 | | - if ( $key < $filterDate ) { |
892 | | - unset( $data[$key] ); |
893 | | - } |
894 | | - } |
895 | | - |
896 | | - $index = substr( wfTimestampNow(), 0, 8 ); |
897 | | - if ( !isset( $data[$index] ) ) { |
898 | | - $data[$index] = array(); |
899 | | - } |
900 | | - |
901 | | - foreach ( self::$instance->mRequestedMessages as $message => $_ ) { |
902 | | - if ( !isset( $data[$index][$message] ) ) { |
903 | | - $data[$index][$message] = 0; |
904 | | - } |
905 | | - $data[$index][$message]++; |
906 | | - } |
907 | | - |
908 | | - $cache->set( $cachekey, $data ); |
909 | | - wfProfileOut( __METHOD__ ); |
910 | | - } |
911 | | - |
912 | | - public function getMostUsedMessages() { |
913 | | - wfProfileIn( __METHOD__ ); |
914 | | - $cachekey = wfMemcKey( 'message-profiling' ); |
915 | | - $cache = wfGetCache( CACHE_DB ); |
916 | | - $data = $cache->get( $cachekey ); |
917 | | - if ( !$data ) { |
918 | | - wfProfileOut( __METHOD__ ); |
919 | | - return array(); |
920 | | - } |
921 | | - |
922 | | - $list = array(); |
923 | | - |
924 | | - foreach( $data as $messages ) { |
925 | | - foreach( $messages as $message => $count ) { |
926 | | - $key = $message; |
927 | | - if ( !isset( $list[$key] ) ) { |
928 | | - $list[$key] = 0; |
929 | | - } |
930 | | - $list[$key] += $count; |
931 | | - } |
932 | | - } |
933 | | - |
934 | | - $max = max( $list ); |
935 | | - foreach ( $list as $message => $count ) { |
936 | | - if ( $count < intval( $max * self::$mAdaptiveInclusionThreshold ) ) { |
937 | | - unset( $list[$message] ); |
938 | | - } |
939 | | - } |
940 | | - |
941 | | - wfProfileOut( __METHOD__ ); |
942 | | - return array_keys( $list ); |
943 | | - } |
944 | | - |
945 | 819 | } |
Property changes on: branches/REL1_18/phase3/includes/cache/MessageCache.php |
___________________________________________________________________ |
Added: svn:mergeinfo |
946 | 820 | Merged /branches/new-installer/phase3/includes/cache/MessageCache.php:r43664-66004 |
947 | 821 | Merged /branches/wmf-deployment/includes/cache/MessageCache.php:r53381 |
948 | 822 | Merged /branches/REL1_17/phase3/includes/MessageCache.php:r81444 |
949 | 823 | Merged /branches/REL1_15/phase3/includes/cache/MessageCache.php:r51646 |
950 | 824 | Merged /branches/REL1_17/phase3/includes/cache/MessageCache.php:r81444 |
951 | 825 | Merged /branches/sqlite/includes/cache/MessageCache.php:r58211-58321 |
Index: branches/REL1_18/phase3/includes/DefaultSettings.php |
— | — | @@ -1566,13 +1566,6 @@ |
1567 | 1567 | $wgLocalMessageCacheSerialized = true; |
1568 | 1568 | |
1569 | 1569 | /** |
1570 | | - * Instead of caching everything, keep track which messages are requested and |
1571 | | - * load only most used messages. This only makes sense if there is lots of |
1572 | | - * interface messages customised in the wiki (like hundreds in many languages). |
1573 | | - */ |
1574 | | -$wgAdaptiveMessageCache = false; |
1575 | | - |
1576 | | -/** |
1577 | 1570 | * Localisation cache configuration. Associative array with keys: |
1578 | 1571 | * class: The class to use. May be overridden by extensions. |
1579 | 1572 | * |