Backed out changeset 4bf710c1a503 (bug 1281793)

This commit is contained in:
Carsten "Tomcat" Book 2016-06-28 17:04:51 +02:00
parent d7c349e036
commit 32708ad758
6 changed files with 75 additions and 9 deletions

View File

@ -1617,6 +1617,9 @@ nsCacheService::CreateDiskDevice()
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

View File

@ -965,12 +965,17 @@ nsDiskCacheDevice::OpenDiskCache()
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))
@ -990,7 +995,7 @@ nsDiskCacheDevice::OpenDiskCache()
// reopen the cache map
nsDiskCache::CorruptCacheInfo corruptInfo;
rv = mCacheMap.Open(mCacheDirectory, &corruptInfo);
rv = mCacheMap.Open(mCacheDirectory, &corruptInfo, false);
if (NS_FAILED(rv))
return rv;
}

View File

@ -34,7 +34,8 @@ using namespace mozilla;
nsresult
nsDiskCacheMap::Open(nsIFile * cacheDirectory,
nsDiskCache::CorruptCacheInfo * corruptInfo)
nsDiskCache::CorruptCacheInfo * corruptInfo,
bool reportCacheCleanTelemetryData)
{
NS_ENSURE_ARG_POINTER(corruptInfo);
@ -65,7 +66,8 @@ nsDiskCacheMap::Open(nsIFile * cacheDirectory,
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;
}
@ -1236,7 +1238,8 @@ nsDiskCacheMap::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf)
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.
@ -1272,6 +1275,9 @@ nsDiskCacheMap::InitCacheClean(nsIFile * cacheDirectory,
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);
}
}
@ -1334,9 +1340,11 @@ nsDiskCacheMap::InvalidateCache()
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;
}
@ -1406,6 +1414,7 @@ nsDiskCacheMap::RevalidateCache()
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
@ -1413,6 +1422,8 @@ nsDiskCacheMap::RevalidateCache()
// 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
@ -1424,9 +1435,11 @@ nsDiskCacheMap::RevalidateCache()
// 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;

View File

@ -408,7 +408,8 @@ public:
* 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();
@ -541,7 +542,8 @@ private:
// 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

View File

@ -1672,6 +1672,32 @@
"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",
@ -1820,6 +1846,11 @@
"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",

View File

@ -382,6 +382,12 @@
"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",
@ -1467,6 +1473,12 @@
"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",