Bug 112862 - IndexedDB: Histogram available disk space on attempt to open database
Summary: IndexedDB: Histogram available disk space on attempt to open database
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Grogan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-20 17:48 PDT by David Grogan
Modified: 2013-03-22 10:36 PDT (History)
11 users (show)

See Also:


Attachments
Patch (4.29 KB, patch)
2013-03-20 17:55 PDT, David Grogan
no flags Details | Formatted Diff | Diff
Patch (4.55 KB, patch)
2013-03-20 17:57 PDT, David Grogan
no flags Details | Formatted Diff | Diff
Patch (4.61 KB, patch)
2013-03-20 18:05 PDT, David Grogan
no flags Details | Formatted Diff | Diff
Patch (4.57 KB, patch)
2013-03-20 18:24 PDT, David Grogan
no flags Details | Formatted Diff | Diff
Patch (4.71 KB, patch)
2013-03-21 16:09 PDT, David Grogan
no flags Details | Formatted Diff | Diff
Patch (4.70 KB, patch)
2013-03-21 22:15 PDT, David Grogan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Grogan 2013-03-20 17:48:35 PDT
IndexedDB: Histogram available disk space on attempt to open database
Comment 1 David Grogan 2013-03-20 17:55:33 PDT
Created attachment 194154 [details]
Patch
Comment 2 David Grogan 2013-03-20 17:57:58 PDT
Created attachment 194155 [details]
Patch
Comment 3 WebKit Review Bot 2013-03-20 18:01:19 PDT
Please wait for approval from abarth@webkit.org, dglazkov@chromium.org, fishd@chromium.org, jamesr@chromium.org or tkent@chromium.org before submitting, as this patch contains changes to the Chromium public API. See also https://trac.webkit.org/wiki/ChromiumWebKitAPI.
Comment 4 David Grogan 2013-03-20 18:05:28 PDT
Created attachment 194156 [details]
Patch
Comment 5 David Grogan 2013-03-20 18:07:06 PDT
As written, this patch requires https://code.google.com/p/chromium/issues/detail?id=222432 to land in chromium first.
Comment 6 David Grogan 2013-03-20 18:16:13 PDT
Josh/Alec, could you give this a look?
Comment 7 David Grogan 2013-03-20 18:24:01 PDT
Created attachment 194160 [details]
Patch
Comment 8 Joshua Bell 2013-03-21 10:13:40 PDT
lgtm
Comment 9 David Grogan 2013-03-21 13:23:26 PDT
WebKit API reviewers - r?
Comment 10 Adam Barth 2013-03-21 13:28:21 PDT
Comment on attachment 194160 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=194160&action=review

> Source/WebCore/platform/leveldb/LevelDBDatabase.cpp:146
> +static void HistogramFreeSpace(const char* type, String fileName)

HistogramFreeSpace -> histogramFreeSpace

> Source/WebCore/platform/leveldb/LevelDBDatabase.cpp:149
> +    String name = String::format("WebCore.IndexedDB.LevelDB.Open%sFreeDiskSpace", type);

You should just use operator+ on String.  It's faster.

> Source/WebCore/platform/leveldb/LevelDBDatabase.cpp:156
> +    HistogramSupport::histogramCustomCounts(name.utf8().data(), clampedDiskSpaceKBytes, 1, 1e9, 11);

Should we COMPILE_ASSERT a relationship between 1e9 and INT_MAX?
Comment 11 Adam Barth 2013-03-21 13:28:57 PDT
Comment on attachment 194160 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=194160&action=review

> Source/Platform/chromium/public/Platform.h:363
> +    virtual long long availableDiskSpaceInBytes(const WebString& fileName) { return 0; }

Is this a blocking call?  Is there a restriction on calling this function from the main thread?
Comment 12 David Grogan 2013-03-21 16:09:35 PDT
Created attachment 194372 [details]
Patch
Comment 13 David Grogan 2013-03-21 16:09:54 PDT
Comment on attachment 194160 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=194160&action=review

>> Source/Platform/chromium/public/Platform.h:363
>> +    virtual long long availableDiskSpaceInBytes(const WebString& fileName) { return 0; }
> 
> Is this a blocking call?  Is there a restriction on calling this function from the main thread?

It does block and probably shouldn't be called from the main thread. Chromium only calls it from the browser process's WebKit thread (aka IndexedDB thread). Is there a way to enforce non-main-thread usage in other ports?

>> Source/WebCore/platform/leveldb/LevelDBDatabase.cpp:146
>> +static void HistogramFreeSpace(const char* type, String fileName)
> 
> HistogramFreeSpace -> histogramFreeSpace

Done.

>> Source/WebCore/platform/leveldb/LevelDBDatabase.cpp:149
>> +    String name = String::format("WebCore.IndexedDB.LevelDB.Open%sFreeDiskSpace", type);
> 
> You should just use operator+ on String.  It's faster.

Done, but semi-awkwardly.

>> Source/WebCore/platform/leveldb/LevelDBDatabase.cpp:156
>> +    HistogramSupport::histogramCustomCounts(name.utf8().data(), clampedDiskSpaceKBytes, 1, 1e9, 11);
> 
> Should we COMPILE_ASSERT a relationship between 1e9 and INT_MAX?

Done, though again semi-awkwardly.
Comment 14 David Grogan 2013-03-21 16:14:03 PDT
Comment on attachment 194372 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=194372&action=review

> Source/Platform/chromium/public/Platform.h:363
> +    virtual long long availableDiskSpaceInBytes(const WebString& fileName) { return 0; }

I said "other ports" forgetting that this platform layer is only available to chromium. Should I put ASSERT(!isMainThread()) somewhere or just leave as is?
Comment 15 Adam Barth 2013-03-21 16:16:05 PDT
(In reply to comment #14)
> (From update of attachment 194372 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=194372&action=review
> 
> > Source/Platform/chromium/public/Platform.h:363
> > +    virtual long long availableDiskSpaceInBytes(const WebString& fileName) { return 0; }
> 
> I said "other ports" forgetting that this platform layer is only available to chromium. Should I put ASSERT(!isMainThread()) somewhere or just leave as is?

We should probably leave it as-is.  I suspect we set the "main thread" bit on the in-process WebKit thread.
Comment 16 Adam Barth 2013-03-21 16:16:26 PDT
Comment on attachment 194372 [details]
Patch

Thanks!
Comment 17 David Grogan 2013-03-21 16:29:57 PDT
(Want to wait until the platformsupport implementation lands so that I don't get confused about unexpected zeros showing up in the histogram)
Comment 18 WebKit Review Bot 2013-03-21 21:05:52 PDT
Comment on attachment 194372 [details]
Patch

Clearing flags on attachment: 194372

Committed r146560: <http://trac.webkit.org/changeset/146560>
Comment 19 WebKit Review Bot 2013-03-21 21:05:58 PDT
All reviewed patches have been landed.  Closing bug.
Comment 20 David Grogan 2013-03-21 22:01:01 PDT
Reverted r146560 for reason:

invalid parameter to histogram

Committed r146561: <http://trac.webkit.org/changeset/146561>
Comment 21 David Grogan 2013-03-21 22:15:25 PDT
Created attachment 194442 [details]
Patch
Comment 22 David Grogan 2013-03-21 22:20:29 PDT
Adam, could I get you to re-review? The only change is on Line 152. "1, 1" became "1, 2" because the boundary is supposed to be higher than the minimum, not equal to it[1].

Untested code == broken code, indeed.

1. https://code.google.com/p/chromium/codesearch#chromium/src/base/metrics/histogram.h&sq=package:chromium&type=cs&l=25
Comment 23 David Grogan 2013-03-21 23:13:42 PDT
Tony, could you review this? It looks like Adam just left for vacation.

It has WebKit API in it, but abarth@ has already approved that part.

History is:
r+ from abarth
committed
rolled out
fixed non webkit-api and reuploaded
now
Comment 24 Tony Chang 2013-03-22 10:29:57 PDT
Comment on attachment 194442 [details]
Patch

OK
Comment 25 WebKit Review Bot 2013-03-22 10:36:46 PDT
Comment on attachment 194442 [details]
Patch

Clearing flags on attachment: 194442

Committed r146628: <http://trac.webkit.org/changeset/146628>
Comment 26 WebKit Review Bot 2013-03-22 10:36:51 PDT
All reviewed patches have been landed.  Closing bug.