Bug 142810

Summary: Prune least valuable cache entries first
Product: WebKit Reporter: Antti Koivisto <koivisto>
Component: Page LoadingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, cdumez
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 229003    
Attachments:
Description Flags
patch
none
patch darin: review+

Description Antti Koivisto 2015-03-17 22:21:00 PDT
Estimat entry value based on its age and access time.
Comment 1 Antti Koivisto 2015-03-17 22:41:29 PDT
Created attachment 248910 [details]
patch
Comment 2 Antti Koivisto 2015-03-17 22:53:02 PDT
Created attachment 248913 [details]
patch
Comment 3 Darin Adler 2015-03-18 08:33:43 PDT
Comment on attachment 248913 [details]
patch

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

> Source/WebKit2/NetworkProcess/cache/NetworkCacheFileSystemPosix.h:87
> +    auto times = fileTimes(path);

It’s a little bit irritating that this function calls fileSystemRepresentation on the path twice, allocating two separate C strings.

> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:312
> +                auto entry = decodeEntry(fileData, channel->fileDescriptor(), read.key);

Is there something that guarantees that the file descriptor is still open at this point? Just extending the lifetime of the IOChannel alone doesn’t seem to guarantee that.

> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:592
> +    if (age <= seconds::zero() || accessAge > age)
> +        return maximumProbability;

No check for accessAge < 0?
Comment 4 Antti Koivisto 2015-03-18 08:58:16 PDT
Comment on attachment 248913 [details]
patch

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

>> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:312
>> +                auto entry = decodeEntry(fileData, channel->fileDescriptor(), read.key);
> 
> Is there something that guarantees that the file descriptor is still open at this point? Just extending the lifetime of the IOChannel alone doesn’t seem to guarantee that.

It should, slightly indirectly. File closes when the underlying dispatch_io closes and IOChannel refs it:

m_dispatchIO = adoptDispatch(dispatch_io_create(DISPATCH_IO_RANDOM, fd, dispatch_get_main_queue(), [fd](int) {
        close(fd);
 }));
Comment 5 Chris Dumez 2015-03-18 09:25:13 PDT
Comment on attachment 248913 [details]
patch

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

> Source/WebKit2/ChangeLog:5
> +

<rdar://problem/19632130>

> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:292
> +    // We update access time

nit: Missing period at the end.
Comment 6 Antti Koivisto 2015-03-18 10:41:33 PDT
https://trac.webkit.org/r181700