Title: [146560] trunk/Source
Revision
146560
Author
[email protected]
Date
2013-03-21 21:03:27 -0700 (Thu, 21 Mar 2013)

Log Message

IndexedDB: Histogram available disk space on attempt to open database
https://bugs.webkit.org/show_bug.cgi?id=112862

Reviewed by Adam Barth.

Source/Platform:

* chromium/public/Platform.h:
(WebKit::Platform::availableDiskSpaceInBytes):
(Platform):

Source/WebCore:

ChromeOS suspects they might be hitting disk corruption when the disks
are nearly full. This patch logs the available space to either the
"success" or the "fail" histogram as appropriate so that the
distributions can be compared.

No new tests - I don't know of a good way to test histograms. Local
printf testing didn't turn up any bugs.

* platform/leveldb/LevelDBDatabase.cpp:
(WebCore::HistogramFreeSpace):
(WebCore):
(WebCore::LevelDBDatabase::open):

Modified Paths

Diff

Modified: trunk/Source/Platform/ChangeLog (146559 => 146560)


--- trunk/Source/Platform/ChangeLog	2013-03-22 03:48:06 UTC (rev 146559)
+++ trunk/Source/Platform/ChangeLog	2013-03-22 04:03:27 UTC (rev 146560)
@@ -1,3 +1,14 @@
+2013-03-21  David Grogan  <[email protected]>
+
+        IndexedDB: Histogram available disk space on attempt to open database
+        https://bugs.webkit.org/show_bug.cgi?id=112862
+
+        Reviewed by Adam Barth.
+
+        * chromium/public/Platform.h:
+        (WebKit::Platform::availableDiskSpaceInBytes):
+        (Platform):
+
 2013-03-21  Mark Pilgrim  <[email protected]>
 
         [Chromium] Removed unused WEBKIT_USE_NEW_WEBFILESYSTEMTYPE flag

Modified: trunk/Source/Platform/chromium/public/Platform.h (146559 => 146560)


--- trunk/Source/Platform/chromium/public/Platform.h	2013-03-22 03:48:06 UTC (rev 146559)
+++ trunk/Source/Platform/chromium/public/Platform.h	2013-03-22 04:03:27 UTC (rev 146560)
@@ -359,7 +359,10 @@
     // Callable from a background WebKit thread.
     virtual void callOnMainThread(void (*func)(void*), void* context) { }
 
+    // Checks the partition/volume where fileName resides.
+    virtual long long availableDiskSpaceInBytes(const WebString& fileName) { return 0; }
 
+
     // Testing -------------------------------------------------------------
 
 #define HAVE_WEBUNITTESTSUPPORT 1

Modified: trunk/Source/WebCore/ChangeLog (146559 => 146560)


--- trunk/Source/WebCore/ChangeLog	2013-03-22 03:48:06 UTC (rev 146559)
+++ trunk/Source/WebCore/ChangeLog	2013-03-22 04:03:27 UTC (rev 146560)
@@ -1,3 +1,23 @@
+2013-03-21  David Grogan  <[email protected]>
+
+        IndexedDB: Histogram available disk space on attempt to open database
+        https://bugs.webkit.org/show_bug.cgi?id=112862
+
+        Reviewed by Adam Barth.
+
+        ChromeOS suspects they might be hitting disk corruption when the disks
+        are nearly full. This patch logs the available space to either the
+        "success" or the "fail" histogram as appropriate so that the
+        distributions can be compared.
+
+        No new tests - I don't know of a good way to test histograms. Local
+        printf testing didn't turn up any bugs.
+
+        * platform/leveldb/LevelDBDatabase.cpp:
+        (WebCore::HistogramFreeSpace):
+        (WebCore):
+        (WebCore::LevelDBDatabase::open):
+
 2013-03-21  Li Yin  <[email protected]>
 
         FileAPI: Remove deprecation warning when ArrayBuffer is in Blob constructor.

Modified: trunk/Source/WebCore/platform/leveldb/LevelDBDatabase.cpp (146559 => 146560)


--- trunk/Source/WebCore/platform/leveldb/LevelDBDatabase.cpp	2013-03-22 03:48:06 UTC (rev 146559)
+++ trunk/Source/WebCore/platform/leveldb/LevelDBDatabase.cpp	2013-03-22 04:03:27 UTC (rev 146560)
@@ -46,6 +46,7 @@
 
 #if PLATFORM(CHROMIUM)
 #include <env_idb.h>
+#include <public/Platform.h>
 #endif
 
 #if !PLATFORM(CHROMIUM)
@@ -142,6 +143,22 @@
     return s.ok();
 }
 
+static void histogramFreeSpace(const char* type, String fileName)
+{
+#if PLATFORM(CHROMIUM)
+    String name = "WebCore.IndexedDB.LevelDB.Open" + String(type) + "FreeDiskSpace";
+    long long freeDiskSpaceInKBytes = WebKit::Platform::current()->availableDiskSpaceInBytes(fileName) / 1024;
+    if (freeDiskSpaceInKBytes < 0) {
+        HistogramSupport::histogramEnumeration("WebCore.IndexedDB.LevelDB.FreeDiskSpaceFailure", 1, 1);
+        return;
+    }
+    int clampedDiskSpaceKBytes = freeDiskSpaceInKBytes > INT_MAX ? INT_MAX : freeDiskSpaceInKBytes;
+    const uint64_t histogramMax = static_cast<uint64_t>(1e9);
+    COMPILE_ASSERT(histogramMax <= INT_MAX, histogramMaxTooBig);
+    HistogramSupport::histogramCustomCounts(name.utf8().data(), clampedDiskSpaceKBytes, 1, histogramMax, 11/*buckets*/);
+#endif
+}
+
 PassOwnPtr<LevelDBDatabase> LevelDBDatabase::open(const String& fileName, const LevelDBComparator* comparator)
 {
     OwnPtr<ComparatorAdapter> comparatorAdapter = adoptPtr(new ComparatorAdapter(comparator));
@@ -166,10 +183,14 @@
             levelDBError = LevelDBIOError;
         HistogramSupport::histogramEnumeration("WebCore.IndexedDB.LevelDBOpenErrors", levelDBError, LevelDBMaxError);
 
+        histogramFreeSpace("Failure", fileName);
+
         LOG_ERROR("Failed to open LevelDB database from %s: %s", fileName.ascii().data(), s.ToString().c_str());
         return nullptr;
     }
 
+    histogramFreeSpace("Success", fileName);
+
     OwnPtr<LevelDBDatabase> result = adoptPtr(new LevelDBDatabase);
     result->m_db = adoptPtr(db);
     result->m_comparatorAdapter = comparatorAdapter.release();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to