Index: branches/REL1_17/phase3/includes/MessageCache.php |
— | — | @@ -42,26 +42,6 @@ |
43 | 43 | /// Variable for tracking which variables are already loaded |
44 | 44 | protected $mLoadedLanguages = array(); |
45 | 45 | |
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 | 46 | function __construct( $memCached, $useDB, $expiry ) { |
67 | 47 | if ( !$memCached ) { |
68 | 48 | $memCached = wfGetCache( CACHE_NONE ); |
— | — | @@ -329,12 +309,12 @@ |
330 | 310 | * $wgMaxMsgCacheEntrySize are assigned a special value, and are loaded |
331 | 311 | * on-demand from the database later. |
332 | 312 | * |
333 | | - * @param $code \string Language code. |
334 | | - * @return \array Loaded messages for storing in caches. |
| 313 | + * @param $code Optional language code, see documenation of load(). |
| 314 | + * @return Array: Loaded messages for storing in caches. |
335 | 315 | */ |
336 | | - function loadFromDB( $code ) { |
| 316 | + function loadFromDB( $code = false ) { |
337 | 317 | wfProfileIn( __METHOD__ ); |
338 | | - global $wgMaxMsgCacheEntrySize, $wgLanguageCode, $wgAdaptiveMessageCache; |
| 318 | + global $wgMaxMsgCacheEntrySize, $wgContLanguageCode; |
339 | 319 | $dbr = wfGetDB( DB_SLAVE ); |
340 | 320 | $cache = array(); |
341 | 321 | |
— | — | @@ -344,24 +324,19 @@ |
345 | 325 | 'page_namespace' => NS_MEDIAWIKI, |
346 | 326 | ); |
347 | 327 | |
348 | | - $mostused = array(); |
349 | | - if ( $wgAdaptiveMessageCache ) { |
350 | | - $mostused = $this->getMostUsedMessages(); |
| 328 | + if ( $code ) { |
| 329 | + # Is this fast enough. Should not matter if the filtering is done in the |
| 330 | + # database or in code. |
351 | 331 | if ( $code !== $wgLanguageCode ) { |
352 | | - foreach ( $mostused as $key => $value ) $mostused[$key] = "$value/$code"; |
| 332 | + # Messages for particular language |
| 333 | + $conds[] = 'page_title' . $dbr->buildLike( $dbr->anyString(), "/$code" ); |
| 334 | + } else { |
| 335 | + # Effectively disallows use of '/' character in NS_MEDIAWIKI for uses |
| 336 | + # other than language code. |
| 337 | + $conds[] = 'page_title NOT' . $dbr->buildLike( $dbr->anyString(), '/', $dbr->anyString() ); |
353 | 338 | } |
354 | 339 | } |
355 | 340 | |
356 | | - if ( count( $mostused ) ) { |
357 | | - $conds['page_title'] = $mostused; |
358 | | - } elseif ( $code !== $wgLanguageCode ) { |
359 | | - $conds[] = 'page_title' . $dbr->buildLike( $dbr->anyString(), "/$code" ); |
360 | | - } else { |
361 | | - # Effectively disallows use of '/' character in NS_MEDIAWIKI for uses |
362 | | - # other than language code. |
363 | | - $conds[] = 'page_title NOT' . $dbr->buildLike( $dbr->anyString(), '/', $dbr->anyString() ); |
364 | | - } |
365 | | - |
366 | 341 | # Conditions to fetch oversized pages to ignore them |
367 | 342 | $bigConds = $conds; |
368 | 343 | $bigConds[] = 'page_len > ' . intval( $wgMaxMsgCacheEntrySize ); |
— | — | @@ -386,12 +361,6 @@ |
387 | 362 | $cache[$row->page_title] = ' ' . Revision::getRevisionText( $row ); |
388 | 363 | } |
389 | 364 | |
390 | | - foreach ( $mostused as $key ) { |
391 | | - if ( !isset( $cache[$key] ) ) { |
392 | | - $cache[$key] = '!NONEXISTENT'; |
393 | | - } |
394 | | - } |
395 | | - |
396 | 365 | $cache['VERSION'] = MSG_CACHE_VERSION; |
397 | 366 | wfProfileOut( __METHOD__ ); |
398 | 367 | return $cache; |
— | — | @@ -566,11 +535,6 @@ |
567 | 536 | $uckey = $wgContLang->ucfirst( $lckey ); |
568 | 537 | } |
569 | 538 | |
570 | | - /* Record each message request, but only once per request. |
571 | | - * This information is not used unless $wgAdaptiveMessageCache |
572 | | - * is enabled. */ |
573 | | - $this->mRequestedMessages[$uckey] = true; |
574 | | - |
575 | 539 | # Try the MediaWiki namespace |
576 | 540 | if( !$this->mDisable && $useDB ) { |
577 | 541 | $title = $uckey; |
— | — | @@ -635,7 +599,8 @@ |
636 | 600 | * @param $code String: code denoting the language to try. |
637 | 601 | */ |
638 | 602 | function getMsgFromNamespace( $title, $code ) { |
639 | | - global $wgAdaptiveMessageCache; |
| 603 | + $type = false; |
| 604 | + $message = false; |
640 | 605 | |
641 | 606 | $this->load( $code ); |
642 | 607 | if ( isset( $this->mCache[$code][$title] ) ) { |
— | — | @@ -644,28 +609,15 @@ |
645 | 610 | return substr( $entry, 1 ); |
646 | 611 | } elseif ( $entry === '!NONEXISTENT' ) { |
647 | 612 | return false; |
648 | | - } elseif( $entry === '!TOO BIG' ) { |
649 | | - // Fall through and try invididual message cache below |
650 | | - |
651 | | - } else { |
652 | | - // XXX: This is not cached in process cache, should it? |
653 | | - $message = false; |
654 | | - wfRunHooks('MessagesPreLoad', array( $title, &$message ) ); |
655 | | - if ( $message !== false ) { |
656 | | - return $message; |
657 | | - } |
658 | | - |
659 | | - /* If message cache is in normal mode, it is guaranteed |
660 | | - * (except bugs) that there is always entry (or placeholder) |
661 | | - * in the cache if message exists. Thus we can do minor |
662 | | - * performance improvement and return false early. |
663 | | - */ |
664 | | - if ( !$wgAdaptiveMessageCache ) { |
665 | | - return false; |
666 | | - } |
667 | 613 | } |
668 | 614 | } |
669 | 615 | |
| 616 | + # Call message hooks, in case they are defined |
| 617 | + wfRunHooks('MessagesPreLoad', array( $title, &$message ) ); |
| 618 | + if ( $message !== false ) { |
| 619 | + return $message; |
| 620 | + } |
| 621 | + |
670 | 622 | # Try the individual message cache |
671 | 623 | $titleKey = wfMemcKey( 'messages', 'individual', $title ); |
672 | 624 | $entry = $this->mMemc->get( $titleKey ); |
— | — | @@ -689,7 +641,6 @@ |
690 | 642 | $this->mCache[$code][$title] = ' ' . $message; |
691 | 643 | $this->mMemc->set( $titleKey, ' ' . $message, $this->mExpiry ); |
692 | 644 | } else { |
693 | | - $message = false; |
694 | 645 | $this->mCache[$code][$title] = '!NONEXISTENT'; |
695 | 646 | $this->mMemc->set( $titleKey, '!NONEXISTENT', $this->mExpiry ); |
696 | 647 | } |
— | — | @@ -832,59 +783,4 @@ |
833 | 784 | return array( $message, $lang ); |
834 | 785 | } |
835 | 786 | |
836 | | - public static function logMessages() { |
837 | | - global $wgMessageCache, $wgAdaptiveMessageCache; |
838 | | - if ( !$wgAdaptiveMessageCache || !$wgMessageCache instanceof MessageCache ) { |
839 | | - return; |
840 | | - } |
841 | | - |
842 | | - $cachekey = wfMemckey( 'message-profiling' ); |
843 | | - $cache = wfGetCache( CACHE_DB ); |
844 | | - $data = $cache->get( $cachekey ); |
845 | | - |
846 | | - if ( !$data ) $data = array(); |
847 | | - |
848 | | - $age = self::$mAdaptiveDataAge; |
849 | | - $filterDate = substr( wfTimestamp( TS_MW, time()-$age ), 0, 8 ); |
850 | | - foreach ( array_keys( $data ) as $key ) { |
851 | | - if ( $key < $filterDate ) unset( $data[$key] ); |
852 | | - } |
853 | | - |
854 | | - $index = substr( wfTimestampNow(), 0, 8 ); |
855 | | - if ( !isset( $data[$index] ) ) $data[$index] = array(); |
856 | | - |
857 | | - foreach ( $wgMessageCache->mRequestedMessages as $message => $_ ) { |
858 | | - if ( !isset( $data[$index][$message] ) ) $data[$index][$message] = 0; |
859 | | - $data[$index][$message]++; |
860 | | - } |
861 | | - |
862 | | - $cache->set( $cachekey, $data ); |
863 | | - } |
864 | | - |
865 | | - public function getMostUsedMessages() { |
866 | | - $cachekey = wfMemckey( 'message-profiling' ); |
867 | | - $cache = wfGetCache( CACHE_DB ); |
868 | | - $data = $cache->get( $cachekey ); |
869 | | - if ( !$data ) return array(); |
870 | | - |
871 | | - $list = array(); |
872 | | - |
873 | | - foreach( $data as $messages ) { |
874 | | - foreach( $messages as $message => $count ) { |
875 | | - $key = $message; |
876 | | - if ( !isset( $list[$key] ) ) $list[$key] = 0; |
877 | | - $list[$key] += $count; |
878 | | - } |
879 | | - } |
880 | | - |
881 | | - $max = max( $list ); |
882 | | - foreach ( $list as $message => $count ) { |
883 | | - if ( $count < intval( $max * self::$mAdaptiveInclusionThreshold ) ) { |
884 | | - unset( $list[$message] ); |
885 | | - } |
886 | | - } |
887 | | - |
888 | | - return array_keys( $list ); |
889 | | - } |
890 | | - |
891 | 787 | } |
Index: branches/REL1_17/phase3/includes/Wiki.php |
— | — | @@ -416,7 +416,6 @@ |
417 | 417 | * Ends this task peacefully |
418 | 418 | */ |
419 | 419 | function restInPeace() { |
420 | | - MessageCache::logMessages(); |
421 | 420 | wfLogProfilingData(); |
422 | 421 | // Commit and close up! |
423 | 422 | $factory = wfGetLBFactory(); |
Index: branches/REL1_17/phase3/includes/DefaultSettings.php |
— | — | @@ -1542,13 +1542,6 @@ |
1543 | 1543 | $wgLocalMessageCacheSerialized = true; |
1544 | 1544 | |
1545 | 1545 | /** |
1546 | | - * Instead of caching everything, keep track which messages are requested and |
1547 | | - * load only most used messages. This only makes sense if there is lots of |
1548 | | - * interface messages customised in the wiki (like hundreds in many languages). |
1549 | | - */ |
1550 | | -$wgAdaptiveMessageCache = false; |
1551 | | - |
1552 | | -/** |
1553 | 1546 | * Localisation cache configuration. Associative array with keys: |
1554 | 1547 | * class: The class to use. May be overridden by extensions. |
1555 | 1548 | * |