bug 709297 - reduce max cache size to 350MiB the next time we have to trash the cache. r=jduell
authorNick Hurley <hurley@todesschaf.org>
Tue, 07 Aug 2012 15:46:33 -0700
changeset 101729 3247ce86f58f5451b2fedb7c1d368d64b475630e
parent 101728 c7231d7d68e88052a93710536272d54b4cbb7750
child 101730 fcb650e7bd6e4cace8668c60d7264465f127655d
push id23250
push useremorley@mozilla.com
push dateWed, 08 Aug 2012 16:23:03 +0000
treeherdermozilla-central@b99a81e70b06 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjduell
bugs709297
milestone17.0a1
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
bug 709297 - reduce max cache size to 350MiB the next time we have to trash the cache. r=jduell
modules/libpref/src/init/all.js
netwerk/cache/nsCacheService.cpp
netwerk/cache/nsCacheService.h
netwerk/cache/nsDiskCacheDevice.cpp
toolkit/components/telemetry/TelemetryHistograms.h
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -31,16 +31,18 @@ pref("general.warnOnAboutConfig", true);
 // maximum number of dated backups to keep at any time
 pref("browser.bookmarks.max_backups",       5);
 
 pref("browser.cache.disk.enable",           true);
 // Is this the first-time smartsizing has been introduced?
 pref("browser.cache.disk.smart_size.first_run", true);
 // Does the user want smart-sizing?
 pref("browser.cache.disk.smart_size.enabled", true);
+// Which max value should we use for smart-sizing?
+pref("browser.cache.disk.smart_size.use_old_max", true);
 // Size (in KB) explicitly set by the user. Used when smart_size.enabled == false
 pref("browser.cache.disk.capacity",         256000);
 // Max-size (in KB) for entries in disk cache. Set to -1 for no limit.
 // (Note: entries bigger than 1/8 of disk-cache are never cached)
 pref("browser.cache.disk.max_entry_size",    51200);  // 50 MB
 pref("browser.cache.memory.enable",         true);
 // -1 = determine dynamically, 0 = none, n = memory capacity in kilobytes
 //pref("browser.cache.memory.capacity",     -1);
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -52,16 +52,19 @@ using namespace mozilla;
     "browser.cache.disk.smart_size.first_run"
 #define DISK_CACHE_SMART_SIZE_ENABLED_PREF \
     "browser.cache.disk.smart_size.enabled"
 #define DISK_CACHE_SMART_SIZE_PREF "browser.cache.disk.smart_size_cached_value"
 #define DISK_CACHE_CAPACITY_PREF    "browser.cache.disk.capacity"
 #define DISK_CACHE_MAX_ENTRY_SIZE_PREF "browser.cache.disk.max_entry_size"
 #define DISK_CACHE_CAPACITY         256000
 
+#define DISK_CACHE_USE_OLD_MAX_SMART_SIZE_PREF \
+    "browser.cache.disk.smart_size.use_old_max"
+
 #define OFFLINE_CACHE_ENABLE_PREF   "browser.cache.offline.enable"
 #define OFFLINE_CACHE_DIR_PREF      "browser.cache.offline.parent_directory"
 #define OFFLINE_CACHE_CAPACITY_PREF "browser.cache.offline.capacity"
 #define OFFLINE_CACHE_CAPACITY      512000
 
 #define MEMORY_CACHE_ENABLE_PREF    "browser.cache.memory.enable"
 #define MEMORY_CACHE_CAPACITY_PREF  "browser.cache.memory.capacity"
 #define MEMORY_CACHE_MAX_ENTRY_SIZE_PREF "browser.cache.memory.max_entry_size"
@@ -79,50 +82,54 @@ static const char * observerList[] = {
     "last-pb-context-exited"
 };
 static const char * prefList[] = { 
     DISK_CACHE_ENABLE_PREF,
     DISK_CACHE_SMART_SIZE_ENABLED_PREF,
     DISK_CACHE_CAPACITY_PREF,
     DISK_CACHE_DIR_PREF,
     DISK_CACHE_MAX_ENTRY_SIZE_PREF,
+    DISK_CACHE_USE_OLD_MAX_SMART_SIZE_PREF,
     OFFLINE_CACHE_ENABLE_PREF,
     OFFLINE_CACHE_CAPACITY_PREF,
     OFFLINE_CACHE_DIR_PREF,
     MEMORY_CACHE_ENABLE_PREF,
     MEMORY_CACHE_CAPACITY_PREF,
     MEMORY_CACHE_MAX_ENTRY_SIZE_PREF,
     CACHE_COMPRESSION_LEVEL_PREF,
     SANITIZE_ON_SHUTDOWN_PREF,
     CLEAR_ON_SHUTDOWN_PREF
 };
 
 // Cache sizes, in KB
 const PRInt32 DEFAULT_CACHE_SIZE = 250 * 1024;  // 250 MB
 const PRInt32 MIN_CACHE_SIZE = 50 * 1024;       //  50 MB
 #ifdef ANDROID
 const PRInt32 MAX_CACHE_SIZE = 200 * 1024;      // 200 MB
+const PRInt32 OLD_MAX_CACHE_SIZE = 200 * 1024;  // 200 MB
 #else
-const PRInt32 MAX_CACHE_SIZE = 1024 * 1024;     //   1 GB
+const PRInt32 MAX_CACHE_SIZE = 350 * 1024;      // 350 MB
+const PRInt32 OLD_MAX_CACHE_SIZE = 1024 * 1024; //   1 GB
 #endif
 // Default cache size was 50 MB for many years until FF 4:
 const PRInt32 PRE_GECKO_2_0_DEFAULT_CACHE_SIZE = 50 * 1024;
 
 class nsCacheProfilePrefObserver : public nsIObserver
 {
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIOBSERVER
 
     nsCacheProfilePrefObserver()
         : mHaveProfile(false)
         , mDiskCacheEnabled(false)
         , mDiskCacheCapacity(0)
         , mDiskCacheMaxEntrySize(-1) // -1 means "no limit"
         , mSmartSizeEnabled(false)
+        , mUseOldMaxSmartSize(false)
         , mOfflineCacheEnabled(false)
         , mOfflineCacheCapacity(0)
         , mMemoryCacheEnabled(true)
         , mMemoryCacheCapacity(-1)
         , mMemoryCacheMaxEntrySize(-1) // -1 means "no limit"
         , mCacheCompressionLevel(CACHE_COMPRESSION_LEVEL)
         , mSanitizeOnShutdown(false)
         , mClearCacheOnShutdown(false)
@@ -137,41 +144,47 @@ public:
     
     bool            DiskCacheEnabled();
     PRInt32         DiskCacheCapacity()         { return mDiskCacheCapacity; }
     void            SetDiskCacheCapacity(PRInt32);
     PRInt32         DiskCacheMaxEntrySize()     { return mDiskCacheMaxEntrySize; }
     nsIFile *       DiskCacheParentDirectory()  { return mDiskCacheParentDirectory; }
     bool            SmartSizeEnabled()          { return mSmartSizeEnabled; }
 
+    bool            UseOldMaxSmartSize()        { return mUseOldMaxSmartSize; }
+    void            SetUseNewMaxSmartSize()     { mUseOldMaxSmartSize = false; }
+
     bool            OfflineCacheEnabled();
     PRInt32         OfflineCacheCapacity()         { return mOfflineCacheCapacity; }
     nsIFile *       OfflineCacheParentDirectory()  { return mOfflineCacheParentDirectory; }
     
     bool            MemoryCacheEnabled();
     PRInt32         MemoryCacheCapacity();
     PRInt32         MemoryCacheMaxEntrySize()     { return mMemoryCacheMaxEntrySize; }
 
     PRInt32         CacheCompressionLevel();
 
     bool            SanitizeAtShutdown() { return mSanitizeOnShutdown && mClearCacheOnShutdown; }
 
     static PRUint32 GetSmartCacheSize(const nsAString& cachePath,
-                                      PRUint32 currentSize);
+                                      PRUint32 currentSize,
+                                      bool useOldMaxSmartSize);
 
 private:
     bool                    PermittedToSmartSize(nsIPrefBranch*, bool firstRun);
     bool                    mHaveProfile;
     
     bool                    mDiskCacheEnabled;
     PRInt32                 mDiskCacheCapacity; // in kilobytes
     PRInt32                 mDiskCacheMaxEntrySize; // in kilobytes
     nsCOMPtr<nsIFile>       mDiskCacheParentDirectory;
     bool                    mSmartSizeEnabled;
 
+    bool                    mUseOldMaxSmartSize;
+
     bool                    mOfflineCacheEnabled;
     PRInt32                 mOfflineCacheCapacity; // in kilobytes
     nsCOMPtr<nsIFile>       mOfflineCacheParentDirectory;
     
     bool                    mMemoryCacheEnabled;
     PRInt32                 mMemoryCacheCapacity; // in kilobytes
     PRInt32                 mMemoryCacheMaxEntrySize; // in kilobytes
 
@@ -237,35 +250,39 @@ private:
     PRInt32 mSmartSize;
 };
 
 
 // Runnable sent from main thread to cacheIO thread
 class nsGetSmartSizeEvent: public nsRunnable
 {
 public:
-    nsGetSmartSizeEvent(const nsAString& cachePath, PRUint32 currentSize)
+    nsGetSmartSizeEvent(const nsAString& cachePath, PRUint32 currentSize,
+                        bool useOldMaxSmartSize)
       : mCachePath(cachePath)
       , mCurrentSize(currentSize)
+      , mUseOldMaxSmartSize(useOldMaxSmartSize)
     {}
    
     // Calculates user's disk space available on a background thread and
     // dispatches this value back to the main thread.
     NS_IMETHOD Run()
     {
         PRUint32 size;
         size = nsCacheProfilePrefObserver::GetSmartCacheSize(mCachePath,
-                                                             mCurrentSize);
+                                                             mCurrentSize,
+                                                             mUseOldMaxSmartSize);
         NS_DispatchToMainThread(new nsSetSmartSizeEvent(size));
         return NS_OK;
     }
 
 private:
     nsString mCachePath;
     PRUint32 mCurrentSize;
+    bool     mUseOldMaxSmartSize;
 };
 
 class nsBlockOnCacheThreadEvent : public nsRunnable {
 public:
     nsBlockOnCacheThreadEvent()
     {
     }
     NS_IMETHOD Run()
@@ -424,16 +441,21 @@ nsCacheProfilePrefObserver::Observe(nsIS
             } else {
                 // Smart sizing switched off: use user specified size
                 rv = branch->GetIntPref(DISK_CACHE_CAPACITY_PREF, &newCapacity);
                 if (NS_FAILED(rv)) 
                     return rv;
                 mDiskCacheCapacity = NS_MAX(0, newCapacity);
                 nsCacheService::SetDiskCacheCapacity(mDiskCacheCapacity);
             }
+        } else if (!strcmp(DISK_CACHE_USE_OLD_MAX_SMART_SIZE_PREF, data.get())) {
+            rv = branch->GetBoolPref(DISK_CACHE_USE_OLD_MAX_SMART_SIZE_PREF,
+                                     &mUseOldMaxSmartSize);
+            if (NS_FAILED(rv))
+                return rv;
         } else if (!strcmp(DISK_CACHE_MAX_ENTRY_SIZE_PREF, data.get())) {
             PRInt32 newMaxSize;
             rv = branch->GetIntPref(DISK_CACHE_MAX_ENTRY_SIZE_PREF,
                                     &newMaxSize);
             if (NS_FAILED(rv)) 
                 return rv;
 
             mDiskCacheMaxEntrySize = NS_MAX(-1, newMaxSize);
@@ -519,20 +541,22 @@ nsCacheProfilePrefObserver::Observe(nsIS
     }
 
     return NS_OK;
 }
 
 // Returns default ("smart") size (in KB) of cache, given available disk space
 // (also in KB)
 static PRUint32
-SmartCacheSize(const PRUint32 availKB)
+SmartCacheSize(const PRUint32 availKB, bool useOldMaxSmartSize)
 {
+    PRUint32 maxSize = useOldMaxSmartSize ? OLD_MAX_CACHE_SIZE : MAX_CACHE_SIZE;
+
     if (availKB > 100 * 1024 * 1024)
-        return MAX_CACHE_SIZE;  // skip computing if we're over 100 GB
+        return maxSize;  // skip computing if we're over 100 GB
 
     // Grow/shrink in 10 MB units, deliberately, so that in the common case we
     // don't shrink cache and evict items every time we startup (it's important
     // that we don't slow down startup benchmarks).
     PRUint32 sz10MBs = 0;
     PRUint32 avail10MBs = availKB / (1024*10);
 
     // .5% of space above 25 GB
@@ -558,49 +582,51 @@ SmartCacheSize(const PRUint32 availKB)
 
     // 20% of space up to 500 MB (10 MB min)
     sz10MBs += NS_MAX<PRUint32>(1, avail10MBs * .2);
 #else
     // 40% of space up to 500 MB (50 MB min)
     sz10MBs += NS_MAX<PRUint32>(5, avail10MBs * .4);
 #endif
 
-    return NS_MIN<PRUint32>(MAX_CACHE_SIZE, sz10MBs * 10 * 1024);
+    return NS_MIN<PRUint32>(maxSize, sz10MBs * 10 * 1024);
 }
 
  /* Computes our best guess for the default size of the user's disk cache, 
   * based on the amount of space they have free on their hard drive. 
   * We use a tiered scheme: the more space available, 
   * the larger the disk cache will be. However, we do not want
   * to enable the disk cache to grow to an unbounded size, so the larger the
   * user's available space is, the smaller of a percentage we take. We set a
   * lower bound of 50MB and an upper bound of 1GB.  
   *
   *@param:  None.
   *@return: The size that the user's disk cache should default to, in kBytes.
   */
 PRUint32
 nsCacheProfilePrefObserver::GetSmartCacheSize(const nsAString& cachePath,
-                                              PRUint32 currentSize)
+                                              PRUint32 currentSize,
+                                              bool useOldMaxSmartSize)
 {
     // Check for free space on device where cache directory lives
     nsresult rv;
     nsCOMPtr<nsIFile> 
         cacheDirectory (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
     if (NS_FAILED(rv) || !cacheDirectory)
         return DEFAULT_CACHE_SIZE;
     rv = cacheDirectory->InitWithPath(cachePath);
     if (NS_FAILED(rv))
         return DEFAULT_CACHE_SIZE;
     PRInt64 bytesAvailable;
     rv = cacheDirectory->GetDiskSpaceAvailable(&bytesAvailable);
     if (NS_FAILED(rv))
         return DEFAULT_CACHE_SIZE;
 
-    return SmartCacheSize((bytesAvailable / 1024) + currentSize);
+    return SmartCacheSize((bytesAvailable / 1024) + currentSize,
+                          useOldMaxSmartSize);
 }
 
 /* Determine if we are permitted to dynamically size the user's disk cache based
  * on their disk space available. We may do this so long as the pref 
  * smart_size.enabled is true.
  */
 bool
 nsCacheProfilePrefObserver::PermittedToSmartSize(nsIPrefBranch* branch, bool
@@ -621,17 +647,18 @@ nsCacheProfilePrefObserver::PermittedToS
                 mSmartSizeEnabled = false;
                 branch->SetBoolPref(DISK_CACHE_SMART_SIZE_ENABLED_PREF,
                                     mSmartSizeEnabled);
                 return mSmartSizeEnabled;
             }
         }
         // Set manual setting to MAX cache size as starting val for any
         // adjustment by user: (bug 559942 comment 65)
-        branch->SetIntPref(DISK_CACHE_CAPACITY_PREF, MAX_CACHE_SIZE);
+        PRInt32 maxSize = mUseOldMaxSmartSize ? OLD_MAX_CACHE_SIZE : MAX_CACHE_SIZE;
+        branch->SetIntPref(DISK_CACHE_CAPACITY_PREF, maxSize);
     }
 
     rv = branch->GetBoolPref(DISK_CACHE_SMART_SIZE_ENABLED_PREF,
                              &mSmartSizeEnabled);
     if (NS_FAILED(rv))
         mSmartSizeEnabled = false;
     return mSmartSizeEnabled;
 }
@@ -652,16 +679,19 @@ nsCacheProfilePrefObserver::ReadPrefs(ns
 
     (void) branch->GetIntPref(DISK_CACHE_MAX_ENTRY_SIZE_PREF,
                               &mDiskCacheMaxEntrySize);
     mDiskCacheMaxEntrySize = NS_MAX(-1, mDiskCacheMaxEntrySize);
     
     (void) branch->GetComplexValue(DISK_CACHE_DIR_PREF,     // ignore error
                                    NS_GET_IID(nsIFile),
                                    getter_AddRefs(mDiskCacheParentDirectory));
+
+    (void) branch->GetBoolPref(DISK_CACHE_USE_OLD_MAX_SMART_SIZE_PREF,
+                               &mUseOldMaxSmartSize);
     
     if (!mDiskCacheParentDirectory) {
         nsCOMPtr<nsIFile>  directory;
 
         // try to get the disk cache parent directory
         rv = NS_GetSpecialDirectory(NS_APP_CACHE_PARENT_DIR,
                                     getter_AddRefs(directory));
         if (NS_FAILED(rv)) {
@@ -1533,16 +1563,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->UseOldMaxSmartSize());
+
     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(),
@@ -1556,16 +1589,75 @@ nsCacheService::CreateDiskDevice()
         NS_WARNING("Can't create smart size timer");
     }
     // Ignore state of the timer and return success since the purpose of the
     // method (create the disk-device) has been fulfilled
 
     return NS_OK;
 }
 
+// Runnable sent from cache thread to main thread
+class nsDisableOldMaxSmartSizePrefEvent: public nsRunnable
+{
+public:
+    nsDisableOldMaxSmartSizePrefEvent() {}
+
+    NS_IMETHOD Run()
+    {
+        // Main thread may have already called nsCacheService::Shutdown
+        if (!nsCacheService::gService || !nsCacheService::gService->mObserver)
+            return NS_ERROR_NOT_AVAILABLE;
+
+        nsDisableOldMaxSmartSizePrefEvent::DisableOldMaxSmartSizePref(true);
+        return NS_OK;
+    }
+
+    static void DisableOldMaxSmartSizePref(bool async)
+    {
+        nsCOMPtr<nsIPrefService> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
+        if (!prefService) {
+            return;
+        }
+
+        nsCOMPtr<nsIPrefBranch> branch;
+        nsresult rv = prefService->GetDefaultBranch(nullptr, getter_AddRefs(branch));
+        if (NS_FAILED(rv)) {
+            return;
+        }
+
+        rv = branch->SetBoolPref(DISK_CACHE_USE_OLD_MAX_SMART_SIZE_PREF, false);
+        if (NS_FAILED(rv)) {
+            return;
+        }
+
+        if (async) {
+            nsCacheService::SetDiskSmartSize();
+        } else {
+            nsCacheService::gService->SetDiskSmartSize_Locked();
+        }
+    }
+};
+
+void
+nsCacheService::MarkStartingFresh()
+{
+    if (!gService->mObserver->UseOldMaxSmartSize()) {
+        // Already using new max, nothing to do here
+        return;
+    }
+
+    gService->mObserver->SetUseNewMaxSmartSize();
+
+    if (NS_IsMainThread()) {
+        nsDisableOldMaxSmartSizePrefEvent::DisableOldMaxSmartSizePref(false);
+    } else {
+        NS_DispatchToMainThread(new nsDisableOldMaxSmartSizePrefEvent());
+    }
+}
+
 nsresult
 nsCacheService::GetOfflineDevice(nsOfflineCacheDevice **aDevice)
 {
     if (!mOfflineDevice) {
         nsresult rv = CreateOfflineDevice();
         NS_ENSURE_SUCCESS(rv, rv);
     }
 
@@ -2893,17 +2985,18 @@ nsCacheService::SetDiskSmartSize_Locked(
 
     if (!mObserver->SmartSizeEnabled())
         return NS_ERROR_NOT_AVAILABLE;
 
     nsAutoString cachePath;
     rv = mObserver->DiskCacheParentDirectory()->GetPath(cachePath);
     if (NS_SUCCEEDED(rv)) {
         nsCOMPtr<nsIRunnable> event =
-            new nsGetSmartSizeEvent(cachePath, mDiskDevice->getCacheSize());
+            new nsGetSmartSizeEvent(cachePath, mDiskDevice->getCacheSize(),
+                                    mObserver->UseOldMaxSmartSize());
         DispatchToCacheIOThread(event);
     } else {
         return NS_ERROR_FAILURE;
     }
 
     return NS_OK;
 }
 
--- a/netwerk/cache/nsCacheService.h
+++ b/netwerk/cache/nsCacheService.h
@@ -104,16 +104,21 @@ public:
 
     static PRInt64   MemoryDeviceSize();
     
     static nsresult  DoomEntry(nsCacheEntry * entry);
 
     static bool      IsStorageEnabledForPolicy_Locked(nsCacheStoragePolicy policy);
 
     /**
+     * Called by disk cache to notify us to use the new max smart size
+     */
+    static void      MarkStartingFresh();
+
+    /**
      * Methods called by nsApplicationCacheService
      */
 
     nsresult GetOfflineDevice(nsOfflineCacheDevice ** aDevice);
 
     /**
      * Creates an offline cache device that works over a specific profile directory.
      * A tool to preload offline cache for profiles different from the current
@@ -179,16 +184,17 @@ public:
 private:
     friend class nsCacheServiceAutoLock;
     friend class nsOfflineCacheDevice;
     friend class nsProcessRequestEvent;
     friend class nsSetSmartSizeEvent;
     friend class nsBlockOnCacheThreadEvent;
     friend class nsSetDiskSmartSizeCallback;
     friend class nsDoomEvent;
+    friend class nsDisableOldMaxSmartSizePrefEvent;
 
     /**
      * Internal Methods
      */
 
     static void      Lock(::mozilla::Telemetry::ID mainThreadLockerID);
     static void      Unlock();
 
--- a/netwerk/cache/nsDiskCacheDevice.cpp
+++ b/netwerk/cache/nsDiskCacheDevice.cpp
@@ -1003,16 +1003,17 @@ nsDiskCacheDevice::OpenDiskCache()
             if (NS_FAILED(rv))
                 return rv;
             exists = false;
         }
     }
 
     // if we don't have a cache directory, create one and open it
     if (!exists) {
+        nsCacheService::MarkStartingFresh();
         rv = mCacheDirectory->Create(nsIFile::DIRECTORY_TYPE, 0777);
         CACHE_LOG_PATH(PR_LOG_ALWAYS, "\ncreate cache directory: %s\n", mCacheDirectory);
         CACHE_LOG_ALWAYS(("mCacheDirectory->Create() = %x\n", rv));
         if (NS_FAILED(rv))
             return rv;
     
         // reopen the cache map     
         nsDiskCache::CorruptCacheInfo corruptInfo;
--- a/toolkit/components/telemetry/TelemetryHistograms.h
+++ b/toolkit/components/telemetry/TelemetryHistograms.h
@@ -203,16 +203,17 @@ HISTOGRAM_ENUMERATED_VALUES(HTTP_OFFLINE
 HISTOGRAM(CACHE_DEVICE_SEARCH, 1, 100, 100, LINEAR, "Time to search cache (ms)")
 HISTOGRAM(CACHE_MEMORY_SEARCH, 1, 100, 100, LINEAR, "Time to search memory cache (ms)")
 HISTOGRAM(CACHE_DISK_SEARCH, 1, 100, 100, LINEAR, "Time to search disk cache (ms)")
 HISTOGRAM(CACHE_OFFLINE_SEARCH, 1, 100, 100, LINEAR, "Time to search offline cache (ms)")
 HISTOGRAM(HTTP_DISK_CACHE_OVERHEAD, 1, 32000000, 100, EXPONENTIAL, "HTTP Disk cache memory overhead (bytes)")
 HISTOGRAM(CACHE_LM_INCONSISTENT, 0, 1, 2, BOOLEAN,  "Cache discovered inconsistent last-modified entry")
 HISTOGRAM(CACHE_SERVICE_LOCK_WAIT, 1, 10000, 10000, LINEAR, "Time spent waiting on the cache service lock (ms)")
 HISTOGRAM(CACHE_SERVICE_LOCK_WAIT_MAINTHREAD, 1, 10000, 10000, LINEAR, "Time spent waiting on the cache service lock on the main thread (ms)")
+HISTOGRAM(DISK_CACHE_SMART_SIZE_USING_OLD_MAX, 0, 1, 2, BOOLEAN, "Whether we are using the old default cache smart size")
 
 #define CACHE_LOCK_HISTOGRAM(x) \
   HISTOGRAM(CACHE_SERVICE_LOCK_WAIT_MAINTHREAD_##x, 1, 10 * 1000, 50, EXPONENTIAL, "Time spent waiting on the cache service lock (ms) on the main thread in " #x)
 
 CACHE_LOCK_HISTOGRAM(NSSETDISKSMARTSIZECALLBACK_NOTIFY)
 CACHE_LOCK_HISTOGRAM(NSPROCESSREQUESTEVENT_RUN)
 CACHE_LOCK_HISTOGRAM(NSOUTPUTSTREAMWRAPPER_LAZYINIT)
 CACHE_LOCK_HISTOGRAM(NSOUTPUTSTREAMWRAPPER_CLOSE)