Backed out changeset 4bf710c1a503 (bug 1281793)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Tue, 28 Jun 2016 17:04:51 +0200
changeset 345064 03b169a1cd5c8fa3f362104d0041ae96fd9a4cf4
parent 345063 5297b24d77200a01bdc21a76871b00e01b7e5bdc
child 345065 c51fe95aa69a401cbbe931c96aa3dc8c601828e2
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1281793
milestone50.0a1
backs out4bf710c1a5034d6af3e30d20d0ab720678920ace
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 4bf710c1a503 (bug 1281793)
netwerk/cache/nsCacheService.cpp
netwerk/cache/nsDiskCacheDevice.cpp
netwerk/cache/nsDiskCacheMap.cpp
netwerk/cache/nsDiskCacheMap.h
toolkit/components/telemetry/Histograms.json
toolkit/components/telemetry/histogram-whitelists.json
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -1612,16 +1612,19 @@ nsCacheService::CreateDiskDevice()
         printf("###\n");
 #endif
         mEnableDiskDevice = false;
         delete mDiskDevice;
         mDiskDevice = nullptr;
         return rv;
     }
 
+    Telemetry::Accumulate(Telemetry::DISK_CACHE_SMART_SIZE_USING_OLD_MAX,
+                          mObserver->ShouldUseOldMaxSmartSize());
+
     NS_ASSERTION(!mSmartSizeTimer, "Smartsize timer was already fired!");
 
     // Disk device is usually created during the startup. Delay smart size
     // calculation to avoid possible massive IO caused by eviction of entries
     // in case the new smart size is smaller than current cache usage.
     mSmartSizeTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
     if (NS_SUCCEEDED(rv)) {
         rv = mSmartSizeTimer->InitWithCallback(new nsSetDiskSmartSizeCallback(),
--- a/netwerk/cache/nsDiskCacheDevice.cpp
+++ b/netwerk/cache/nsDiskCacheDevice.cpp
@@ -960,22 +960,27 @@ nsDiskCacheDevice::OpenDiskCache()
     bool exists;
     nsresult rv = mCacheDirectory->Exists(&exists);
     if (NS_FAILED(rv))
         return rv;
 
     if (exists) {
         // Try opening cache map file.
         nsDiskCache::CorruptCacheInfo corruptInfo;
-        rv = mCacheMap.Open(mCacheDirectory, &corruptInfo);
+        rv = mCacheMap.Open(mCacheDirectory, &corruptInfo, true);
 
-        if (rv == NS_ERROR_ALREADY_INITIALIZED) {
+        if (NS_SUCCEEDED(rv)) {
+            Telemetry::Accumulate(Telemetry::DISK_CACHE_CORRUPT_DETAILS,
+                                  corruptInfo);
+        } else if (rv == NS_ERROR_ALREADY_INITIALIZED) {
           NS_WARNING("nsDiskCacheDevice::OpenDiskCache: already open!");
-        } else if (NS_FAILED(rv)) {
+        } else {
             // Consider cache corrupt: delete it
+            Telemetry::Accumulate(Telemetry::DISK_CACHE_CORRUPT_DETAILS,
+                                  corruptInfo);
             // delay delete by 1 minute to avoid IO thrash at startup
             rv = nsDeleteDir::DeleteDir(mCacheDirectory, true, 60000);
             if (NS_FAILED(rv))
                 return rv;
             exists = false;
         }
     }
 
@@ -985,17 +990,17 @@ nsDiskCacheDevice::OpenDiskCache()
         rv = mCacheDirectory->Create(nsIFile::DIRECTORY_TYPE, 0777);
         CACHE_LOG_PATH(LogLevel::Info, "\ncreate cache directory: %s\n", mCacheDirectory);
         CACHE_LOG_INFO(("mCacheDirectory->Create() = %x\n", rv));
         if (NS_FAILED(rv))
             return rv;
     
         // reopen the cache map     
         nsDiskCache::CorruptCacheInfo corruptInfo;
-        rv = mCacheMap.Open(mCacheDirectory, &corruptInfo);
+        rv = mCacheMap.Open(mCacheDirectory, &corruptInfo, false);
         if (NS_FAILED(rv))
             return rv;
     }
 
     return NS_OK;
 }
 
 
--- a/netwerk/cache/nsDiskCacheMap.cpp
+++ b/netwerk/cache/nsDiskCacheMap.cpp
@@ -29,17 +29,18 @@ using namespace mozilla;
  *****************************************************************************/
 
 /**
  *  File operations
  */
 
 nsresult
 nsDiskCacheMap::Open(nsIFile *  cacheDirectory,
-                     nsDiskCache::CorruptCacheInfo *  corruptInfo)
+                     nsDiskCache::CorruptCacheInfo *  corruptInfo,
+                     bool reportCacheCleanTelemetryData)
 {
     NS_ENSURE_ARG_POINTER(corruptInfo);
 
     // Assume we have an unexpected error until we find otherwise.
     *corruptInfo = nsDiskCache::kUnexpectedError;
     NS_ENSURE_ARG_POINTER(cacheDirectory);
     if (mMapFD)  return NS_ERROR_ALREADY_INITIALIZED;
 
@@ -60,17 +61,18 @@ nsDiskCacheMap::Open(nsIFile *  cacheDir
         return NS_ERROR_FILE_CORRUPTED;
     }
 
     bool cacheFilesExist = CacheFilesExist();
     rv = NS_ERROR_FILE_CORRUPTED;  // presume the worst
     uint32_t mapSize = PR_Available(mMapFD);    
 
     if (NS_FAILED(InitCacheClean(cacheDirectory,
-                                 corruptInfo))) {
+                                 corruptInfo,
+                                 reportCacheCleanTelemetryData))) {
         // corruptInfo is set in the call to InitCacheClean
         goto error_exit;
     }
 
     // check size of map file
     if (mapSize == 0) {  // creating a new _CACHE_MAP_
 
         // block files shouldn't exist if we're creating the _CACHE_MAP_
@@ -1231,17 +1233,18 @@ nsDiskCacheMap::SizeOfExcludingThis(Mall
     usage += mBlockFile[i].SizeOfExcludingThis(aMallocSizeOf);
   }
 
   return usage;
 }
 
 nsresult
 nsDiskCacheMap::InitCacheClean(nsIFile *  cacheDirectory,
-                               nsDiskCache::CorruptCacheInfo *  corruptInfo)
+                               nsDiskCache::CorruptCacheInfo *  corruptInfo,
+                               bool reportCacheCleanTelemetryData)
 {
     // The _CACHE_CLEAN_ file will be used in the future to determine
     // if the cache is clean or not. 
     bool cacheCleanFileExists = false;
     nsCOMPtr<nsIFile> cacheCleanFile;
     nsresult rv = cacheDirectory->GetParent(getter_AddRefs(cacheCleanFile));
     if (NS_SUCCEEDED(rv)) {
         rv = cacheCleanFile->AppendNative(
@@ -1267,16 +1270,19 @@ nsDiskCacheMap::InitCacheClean(nsIFile *
         return rv;
     }
 
     if (cacheCleanFileExists) {
         char clean = '0';
         int32_t bytesRead = PR_Read(mCleanFD, &clean, 1);
         if (bytesRead != 1) {
             NS_WARNING("Could not read _CACHE_CLEAN_ file contents");
+        } else if (reportCacheCleanTelemetryData) {
+            Telemetry::Accumulate(Telemetry::DISK_CACHE_REDUCTION_TRIAL,
+                                  clean == '1' ? 1 : 0);
         }
     }
 
     // Create a timer that will be used to validate the cache
     // as long as an activity threshold was met
     mCleanCacheTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
     if (NS_SUCCEEDED(rv)) {
         mCleanCacheTimer->SetTarget(nsCacheService::GlobalInstance()->mCacheIOThread);
@@ -1329,19 +1335,21 @@ nsDiskCacheMap::InvalidateCache()
 {
     nsCacheService::AssertOwnsLock();
     CACHE_LOG_DEBUG(("CACHE: InvalidateCache\n"));
     nsresult rv;
   
     if (!mIsDirtyCacheFlushed) {
         rv = WriteCacheClean(false);
         if (NS_FAILED(rv)) {
+          Telemetry::Accumulate(Telemetry::DISK_CACHE_INVALIDATION_SUCCESS, 0);
           return rv;
         }
 
+        Telemetry::Accumulate(Telemetry::DISK_CACHE_INVALIDATION_SUCCESS, 1);
         mIsDirtyCacheFlushed = true;
     }
 
     rv = ResetCacheTimer();
     NS_ENSURE_SUCCESS(rv, rv);
 
     return NS_OK;
 }
@@ -1401,33 +1409,38 @@ nsDiskCacheMap::IsCacheInSafeState()
 
 nsresult
 nsDiskCacheMap::RevalidateCache()
 {
     CACHE_LOG_DEBUG(("CACHE: RevalidateCache\n"));
     nsresult rv;
 
     if (!IsCacheInSafeState()) {
+        Telemetry::Accumulate(Telemetry::DISK_CACHE_REVALIDATION_SAFE, 0);
         CACHE_LOG_DEBUG(("CACHE: Revalidation should not performed because "
                          "cache not in a safe state\n"));
         // Normally we would return an error here, but there is a bug where
         // the doom list sometimes gets an entry 'stuck' and doens't clear it
         // until browser shutdown.  So we allow revalidation for the time being
         // to get proper telemetry data of how much the cache corruption plan
         // would help.
+    } else {
+        Telemetry::Accumulate(Telemetry::DISK_CACHE_REVALIDATION_SAFE, 1);
     }
 
     // We want this after the lock to prove that flushing a file isn't that expensive
     Telemetry::AutoTimer<Telemetry::NETWORK_DISK_CACHE_REVALIDATION> totalTimer;
 
     // If telemetry data shows it is worth it, we'll be flushing headers and
     // records before flushing the clean cache file.
   
     // Write out the _CACHE_CLEAN_ file with '1'
     rv = WriteCacheClean(true);
     if (NS_FAILED(rv)) {
+        Telemetry::Accumulate(Telemetry::DISK_CACHE_REVALIDATION_SUCCESS, 0);
         return rv;
     }
 
+    Telemetry::Accumulate(Telemetry::DISK_CACHE_REVALIDATION_SUCCESS, 1);
     mIsDirtyCacheFlushed = false;
 
     return NS_OK;
 }
--- a/netwerk/cache/nsDiskCacheMap.h
+++ b/netwerk/cache/nsDiskCacheMap.h
@@ -403,17 +403,18 @@ public:
  *  File Operations
  *
  *  Open
  *
  *  Creates a new cache map file if one doesn't exist.
  *  Returns error if it detects change in format or cache wasn't closed.
  */
     nsresult  Open( nsIFile *  cacheDirectory,
-                    nsDiskCache::CorruptCacheInfo *  corruptInfo);
+                    nsDiskCache::CorruptCacheInfo *  corruptInfo,
+                    bool reportCacheCleanTelemetryData);
     nsresult  Close(bool flush);
     nsresult  Trim();
 
     nsresult  FlushHeader();
     nsresult  FlushRecords( bool unswap);
 
     void      NotifyCapacityChange(uint32_t capacity);
 
@@ -536,17 +537,18 @@ private:
 
     // The returned structure will point to the buffer owned by nsDiskCacheMap, 
     // so it must not be deleted by the caller.
     nsDiskCacheEntry *  CreateDiskCacheEntry(nsDiskCacheBinding *  binding,
                                              uint32_t * size);
 
     // Initializes the _CACHE_CLEAN_ related functionality
     nsresult InitCacheClean(nsIFile *  cacheDirectory,
-                            nsDiskCache::CorruptCacheInfo *  corruptInfo);
+                            nsDiskCache::CorruptCacheInfo *  corruptInfo,
+                            bool reportCacheCleanTelemetryData);
     // Writes out a value of '0' or '1' in the _CACHE_CLEAN_ file
     nsresult WriteCacheClean(bool clean);
     // Resets the timout for revalidating the cache
     nsresult ResetCacheTimer(int32_t timeout = kRevalidateCacheTimeout);
     // Invalidates the cache, calls WriteCacheClean and ResetCacheTimer
     nsresult InvalidateCache();
     // Determines if the cache is in a safe state
     bool IsCacheInSafeState();
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -1667,16 +1667,42 @@
     "n_values": 32,
     "description": "H2: goaway reason from peer from rfc 7540. 31 is none received."
   },
   "HTTP_CONNECTION_ENTRY_CACHE_HIT_1" : {
     "expires_in_version": "never",
     "kind": "boolean",
     "description": "Fraction of sockets that used a nsConnectionEntry with history - size 300."
   },
+  "DISK_CACHE_CORRUPT_DETAILS": {
+    "expires_in_version": "40",
+    "kind": "enumerated",
+    "n_values": 50,
+    "description": "Why the HTTP disk cache was corrupted at startup"
+  },
+  "DISK_CACHE_REDUCTION_TRIAL": {
+    "expires_in_version": "40",
+    "kind": "boolean",
+    "description": "Stores 1 if the cache would be clean with the disk cache corruption plan of Bug 105843"
+  },
+  "DISK_CACHE_REVALIDATION_SAFE": {
+    "expires_in_version": "40",
+    "kind": "boolean",
+    "description": "Stores 1 if the cache clean file was revalidated, or 0 if a non empty doom list prevented revalidation"
+  },
+  "DISK_CACHE_INVALIDATION_SUCCESS": {
+    "expires_in_version": "40",
+    "kind": "boolean",
+    "description": "Stores 1 if writing '0' to the cache clean file succeeded, and 0 if it failed."
+  },
+  "DISK_CACHE_REVALIDATION_SUCCESS": {
+    "expires_in_version": "40",
+    "kind": "boolean",
+    "description": "Stores 1 if writing '1' to the cache clean file succeeded, and 0 if it failed."
+  },
   "HTTP_CACHE_DISPOSITION_2": {
     "expires_in_version": "never",
     "kind": "enumerated",
     "n_values": 5,
     "description": "HTTP Cache Hit, Reval, Failed-Reval, Miss"
   },
   "HTTP_CACHE_DISPOSITION_2_V2": {
     "expires_in_version": "never",
@@ -1815,16 +1841,21 @@
   },
   "CACHE_SERVICE_LOCK_WAIT_MAINTHREAD_2": {
     "expires_in_version": "never",
     "kind": "exponential",
     "high": 10000,
     "n_buckets": 50,
     "description": "Time spent waiting on the cache service lock on the main thread (ms)"
   },
+  "DISK_CACHE_SMART_SIZE_USING_OLD_MAX": {
+    "expires_in_version": "40",
+    "kind": "boolean",
+    "description": "Whether we are using the old default cache smart size"
+  },
   "CACHE_SERVICE_LOCK_WAIT_MAINTHREAD_NSSETDISKSMARTSIZECALLBACK_NOTIFY": {
     "expires_in_version": "never",
     "kind": "exponential",
     "high": 10000,
     "n_buckets": 50,
     "description": "Time spent waiting on the cache service lock (ms) on the main thread in NSSETDISKSMARTSIZECALLBACK_NOTIFY"
   },
   "CACHE_SERVICE_LOCK_WAIT_MAINTHREAD_NSPROCESSREQUESTEVENT_RUN": {
--- a/toolkit/components/telemetry/histogram-whitelists.json
+++ b/toolkit/components/telemetry/histogram-whitelists.json
@@ -377,16 +377,22 @@
     "DEVTOOLS_WEBIDE_PROJECT_EDITOR_SAVE_BOOLEAN",
     "DEVTOOLS_WEBIDE_PROJECT_EDITOR_SAVE_PER_USER_FLAG",
     "DEVTOOLS_WEBIDE_PROJECT_EDITOR_TIME_ACTIVE_SECONDS",
     "DEVTOOLS_WEBIDE_REMOTE_CONNECTION_RESULT",
     "DEVTOOLS_WEBIDE_SIMULATOR_CONNECTION_RESULT",
     "DEVTOOLS_WEBIDE_TIME_ACTIVE_SECONDS",
     "DEVTOOLS_WEBIDE_USB_CONNECTION_RESULT",
     "DEVTOOLS_WEBIDE_WIFI_CONNECTION_RESULT",
+    "DISK_CACHE_CORRUPT_DETAILS",
+    "DISK_CACHE_INVALIDATION_SUCCESS",
+    "DISK_CACHE_REDUCTION_TRIAL",
+    "DISK_CACHE_REVALIDATION_SAFE",
+    "DISK_CACHE_REVALIDATION_SUCCESS",
+    "DISK_CACHE_SMART_SIZE_USING_OLD_MAX",
     "DISPLAY_SCALING_LINUX",
     "DISPLAY_SCALING_MSWIN",
     "DISPLAY_SCALING_OSX",
     "DNS_BLACKLIST_COUNT",
     "DNS_CLEANUP_AGE",
     "DNS_FAILED_LOOKUP_TIME",
     "DNS_LOOKUP_METHOD2",
     "DNS_LOOKUP_TIME",
@@ -1462,16 +1468,22 @@
     "DEVTOOLS_WEBIDE_PROJECT_EDITOR_SAVE_BOOLEAN",
     "DEVTOOLS_WEBIDE_PROJECT_EDITOR_SAVE_PER_USER_FLAG",
     "DEVTOOLS_WEBIDE_PROJECT_EDITOR_TIME_ACTIVE_SECONDS",
     "DEVTOOLS_WEBIDE_REMOTE_CONNECTION_RESULT",
     "DEVTOOLS_WEBIDE_SIMULATOR_CONNECTION_RESULT",
     "DEVTOOLS_WEBIDE_TIME_ACTIVE_SECONDS",
     "DEVTOOLS_WEBIDE_USB_CONNECTION_RESULT",
     "DEVTOOLS_WEBIDE_WIFI_CONNECTION_RESULT",
+    "DISK_CACHE_CORRUPT_DETAILS",
+    "DISK_CACHE_INVALIDATION_SUCCESS",
+    "DISK_CACHE_REDUCTION_TRIAL",
+    "DISK_CACHE_REVALIDATION_SAFE",
+    "DISK_CACHE_REVALIDATION_SUCCESS",
+    "DISK_CACHE_SMART_SIZE_USING_OLD_MAX",
     "DISPLAY_SCALING_LINUX",
     "DISPLAY_SCALING_MSWIN",
     "DISPLAY_SCALING_OSX",
     "DNS_BLACKLIST_COUNT",
     "DNS_CLEANUP_AGE",
     "DNS_FAILED_LOOKUP_TIME",
     "DNS_LOOKUP_METHOD2",
     "DNS_LOOKUP_TIME",