jenkins-bot has submitted this change and it was merged.

Change subject: Made SwiftFileBackend::loadObjectListing() populate stat 
entries in reverse order.
......................................................................


Made SwiftFileBackend::loadObjectListing() populate stat entries in reverse 
order.

Change-Id: I07bf9c852729d65cee72364ca3249e31936d0562
---
M includes/filebackend/SwiftFileBackend.php
1 file changed, 6 insertions(+), 2 deletions(-)

Approvals:
  Demon: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/filebackend/SwiftFileBackend.php 
b/includes/filebackend/SwiftFileBackend.php
index f9e2ce4..54a90d3 100644
--- a/includes/filebackend/SwiftFileBackend.php
+++ b/includes/filebackend/SwiftFileBackend.php
@@ -1111,7 +1111,11 @@
                $names = array();
                $storageDir = rtrim( $params['dir'], '/' );
                $suffixStart = ( $dir === '' ) ? 0 : strlen( $dir ) + 1; // 
size of "path/to/dir/"
-               foreach ( $cfObjects as $object ) {
+               // Iterate over the list *backwards* as this primes the stat 
cache, which is LRU.
+               // If this fills the cache and the caller stats an uncached 
file before stating
+               // the ones on the listing, there would be zero cache hits if 
this went forwards.
+               for ( end( $cfObjects ); key( $cfObjects ) !== null; prev( 
$cfObjects ) ) {
+                       $object = current( $cfObjects );
                        $path = "{$storageDir}/" . substr( $object->name, 
$suffixStart );
                        $val = array(
                                // Convert dates like "Tue, 03 Jan 2012 
22:01:04 GMT" to TS_MW
@@ -1122,7 +1126,7 @@
                        $this->cheapCache->set( $path, 'stat', $val );
                        $names[] = $object->name;
                }
-               return $names;
+               return array_reverse( $names ); // keep the paths in original 
order
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/64534
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I07bf9c852729d65cee72364ca3249e31936d0562
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Demon <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to