Bug 141378 - Measure cache size more accurately
Summary: Measure cache size more accurately
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-08 16:59 PST by Antti Koivisto
Modified: 2015-02-09 03:36 PST (History)
1 user (show)

See Also:


Attachments
patch (8.43 KB, patch)
2015-02-08 17:15 PST, Antti Koivisto
cdumez: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koivisto 2015-02-08 16:59:00 PST
Currently we just estimate from the item count.
Comment 1 Antti Koivisto 2015-02-08 17:15:51 PST
Created attachment 246253 [details]
patch
Comment 2 Antti Koivisto 2015-02-08 17:16:39 PST
rdar://problem/19760224
Comment 3 Chris Dumez 2015-02-08 19:33:41 PST
Comment on attachment 246253 [details]
patch

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

r=me with comments

> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorageCocoa.mm:458
> +            m_approximateSize += bodyOffset + bodySize;

Why are we adding an offset to the size here? Maybe it is just a naming issue but it looks wrong.

> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorageCocoa.mm:554
> +    static const double deletionProbability { 0.25 };

Maybe a ASSERT(RunLoop::isMain()); before this?

> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorageCocoa.mm:572
> +            bool shouldDelete = randomNumber() < deletionProbability;

Is it safe to call randomNumber() from another thread? The implementation seems to call sharedRandomNumberGenerator() which is a singleton.
Comment 4 Antti Koivisto 2015-02-09 02:11:13 PST
> Is it safe to call randomNumber() from another thread? The implementation
> seems to call sharedRandomNumberGenerator() which is a singleton.

sharedRandomNumberGenerator() is ARC4RandomNumberGenerator which is thread safe (internal mutex).
Comment 5 Antti Koivisto 2015-02-09 03:36:07 PST
http://trac.webkit.org/changeset/179823