[FileBackend] Reduced stat calls when using the multiwrite backend.
authorAaron Schulz <aschulz@wikimedia.org>
Sun, 26 Aug 2012 09:11:31 +0000 (02:11 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sun, 26 Aug 2012 09:11:31 +0000 (02:11 -0700)
Change-Id: I46805637a9dcaaea597bf6eeba204a6889a36a51

includes/filebackend/FileBackend.php
includes/filebackend/FileBackendMultiWrite.php
includes/filebackend/FileBackendStore.php

index 4b707fc..daa8f22 100644 (file)
@@ -242,6 +242,9 @@ abstract class FileBackend {
         *   - allowStale          : Don't require the latest available data.
         *                           This can increase performance for non-critical writes.
         *                           This has no effect unless the 'force' flag is set.
+        *   - preserveCache       : Don't clear the process cache before checking files.
+        *                           This should only be used if all entries in the process
+        *                           cache were added after the files were already locked.
         *   - nonJournaled        : Don't log this operation batch in the file journal.
         *                           This limits the ability of recovery scripts.
         *   - parallelize         : Try to do operations in parallel when possible.
index 0c8968a..59392f6 100644 (file)
@@ -151,6 +151,7 @@ class FileBackendMultiWrite extends FileBackend {
                }
                // Clear any cache entries (after locks acquired)
                $this->clearCache();
+               $opts['preserveCache'] = true; // only locked files are cached
                // Do a consistency check to see if the backends agree
                $status->merge( $this->consistencyCheck( $this->fileStoragePathsForOps( $ops ) ) );
                if ( !$status->isOK() ) {
index 852a653..9311a90 100644 (file)
@@ -989,7 +989,9 @@ abstract class FileBackendStore extends FileBackend {
                }
 
                // Clear any file cache entries (after locks acquired)
-               $this->clearCache();
+               if ( empty( $opts['preserveCache'] ) ) {
+                       $this->clearCache();
+               }
 
                // Load from the persistent file and container caches
                $this->primeFileCache( $performOps );