Bug 142810 - Prune least valuable cache entries first
Summary: Prune least valuable cache entries first
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: InRadar
Depends on:
Blocks: 229003
  Show dependency treegraph
 
Reported: 2015-03-17 22:21 PDT by Antti Koivisto
Modified: 2021-08-11 08:35 PDT (History)
2 users (show)

See Also:


Attachments
patch (12.49 KB, patch)
2015-03-17 22:41 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (12.41 KB, patch)
2015-03-17 22:53 PDT, Antti Koivisto
darin: 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-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