Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Issue 10909136: Http Cache: Add code for simulating an infinite HTTP cache. (Closed)

Created:
8 years, 3 months ago by rvargas (doing something else)
Modified:
8 years, 3 months ago
CC:
chromium-reviews, cbentzel+watch_chromium.org, darin-cc_chromium.org, gavinp+disk_chromium.org
Visibility:
Public.

Description

Http Cache: Add code for simulating an infinite HTTP cache. This is not completely wired yet. BUg=147383 TEST=net_unittests Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=156846

Patch Set 1 #

Total comments: 63

Patch Set 2 : rebase after update #

Patch Set 3 : #

Total comments: 4

Patch Set 4 : #

Patch Set 5 : Add HttpCache getter #

Total comments: 1

Patch Set 6 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1419 lines, -5 lines) Patch
M net/http/http_cache.h View 1 2 3 4 4 chunks +7 lines, -0 lines 0 comments Download
M net/http/http_cache.cc View 1 3 chunks +7 lines, -3 lines 0 comments Download
M net/http/http_cache_transaction.h View 1 2 chunks +4 lines, -1 line 0 comments Download
M net/http/http_cache_transaction.cc View 1 6 chunks +27 lines, -1 line 0 comments Download
A net/http/infinite_cache.h View 1 2 1 chunk +120 lines, -0 lines 0 comments Download
A net/http/infinite_cache.cc View 1 2 3 4 5 1 chunk +1017 lines, -0 lines 0 comments Download
A net/http/infinite_cache_unittest.cc View 1 2 1 chunk +234 lines, -0 lines 0 comments Download
M net/net.gyp View 1 2 chunks +3 lines, -0 lines 0 comments Download

Messages

Total messages: 17 (0 generated)
rvargas (doing something else)
8 years, 3 months ago (2012-09-07 23:27:29 UTC) #1
willchan no longer on Chromium
http://codereview.chromium.org/10909136/diff/1/net/http/http_cache_transaction.cc File net/http/http_cache_transaction.cc (right): http://codereview.chromium.org/10909136/diff/1/net/http/http_cache_transaction.cc#newcode255 net/http/http_cache_transaction.cc:255: if ((effective_load_flags_ & LOAD_BYPASS_CACHE) || I'm not really sure ...
8 years, 3 months ago (2012-09-10 20:47:05 UTC) #2
willchan no longer on Chromium
Yeah, despite my interest in this, I think deferring the review to Gavin makes more ...
8 years, 3 months ago (2012-09-10 20:48:20 UTC) #3
gavinp
On 2012/09/10 20:48:20, willchan wrote: > Yeah, despite my interest in this, I think deferring ...
8 years, 3 months ago (2012-09-11 05:44:01 UTC) #4
tburkard
My first set of comments. Overall, looks pretty good! I guess there are still a ...
8 years, 3 months ago (2012-09-11 21:02:00 UTC) #5
gavinp
Also, Timo's comment about NO_STORE touches on an assumption that this code makes. There's at ...
8 years, 3 months ago (2012-09-13 04:45:42 UTC) #6
rvargas (doing something else)
On 2012/09/10 20:48:20, willchan wrote: > Yeah, despite my interest in this, I think deferring ...
8 years, 3 months ago (2012-09-13 21:28:49 UTC) #7
rvargas (doing something else)
First round of comments. Code to follow. http://codereview.chromium.org/10909136/diff/1/net/http/infinite_cache.cc File net/http/infinite_cache.cc (right): http://codereview.chromium.org/10909136/diff/1/net/http/infinite_cache.cc#newcode49 net/http/infinite_cache.cc:49: }; On ...
8 years, 3 months ago (2012-09-13 22:44:06 UTC) #8
rvargas (doing something else)
http://codereview.chromium.org/10909136/diff/1/net/http/infinite_cache.cc File net/http/infinite_cache.cc (right): http://codereview.chromium.org/10909136/diff/1/net/http/infinite_cache.cc#newcode208 net/http/infinite_cache.cc:208: return adler32(hash, reinterpret_cast<const Bytef*>(pickle.data()), On 2012/09/13 04:45:43, gavinp wrote: ...
8 years, 3 months ago (2012-09-13 23:08:19 UTC) #9
rvargas (doing something else)
New version up. http://codereview.chromium.org/10909136/diff/1/net/http/infinite_cache.cc File net/http/infinite_cache.cc (right): http://codereview.chromium.org/10909136/diff/1/net/http/infinite_cache.cc#newcode55 net/http/infinite_cache.cc:55: }; On 2012/09/13 04:45:43, gavinp wrote: ...
8 years, 3 months ago (2012-09-13 23:50:28 UTC) #10
tburkard
http://codereview.chromium.org/10909136/diff/14001/net/http/infinite_cache.cc File net/http/infinite_cache.cc (right): http://codereview.chromium.org/10909136/diff/14001/net/http/infinite_cache.cc#newcode513 net/http/infinite_cache.cc:513: RecordHit(i->second, &data->details); Shouldn't we record a hit even if ...
8 years, 3 months ago (2012-09-14 01:01:49 UTC) #11
rvargas (doing something else)
http://codereview.chromium.org/10909136/diff/14001/net/http/infinite_cache.cc File net/http/infinite_cache.cc (right): http://codereview.chromium.org/10909136/diff/14001/net/http/infinite_cache.cc#newcode513 net/http/infinite_cache.cc:513: RecordHit(i->second, &data->details); On 2012/09/14 01:01:49, tburkard wrote: > Shouldn't ...
8 years, 3 months ago (2012-09-14 01:13:24 UTC) #12
tburkard
http://codereview.chromium.org/10909136/diff/14001/net/http/infinite_cache.cc File net/http/infinite_cache.cc (right): http://codereview.chromium.org/10909136/diff/14001/net/http/infinite_cache.cc#newcode513 net/http/infinite_cache.cc:513: RecordHit(i->second, &data->details); Sorry, I just meant double counting didn't ...
8 years, 3 months ago (2012-09-14 01:18:49 UTC) #13
rvargas (doing something else)
http://codereview.chromium.org/10909136/diff/14001/net/http/infinite_cache.cc File net/http/infinite_cache.cc (right): http://codereview.chromium.org/10909136/diff/14001/net/http/infinite_cache.cc#newcode513 net/http/infinite_cache.cc:513: RecordHit(i->second, &data->details); Agreed. done.
8 years, 3 months ago (2012-09-14 01:34:52 UTC) #14
gavinp
lgtm. None of my nits are major enough to block this. I will take a ...
8 years, 3 months ago (2012-09-14 03:27:28 UTC) #15
tburkard
lgtm
8 years, 3 months ago (2012-09-14 16:52:59 UTC) #16
rvargas (doing something else)
8 years, 3 months ago (2012-09-14 18:37:18 UTC) #17
thanks

http://codereview.chromium.org/10909136/diff/1/net/http/infinite_cache.cc
File net/http/infinite_cache.cc (right):

http://codereview.chromium.org/10909136/diff/1/net/http/infinite_cache.cc#new...
net/http/infinite_cache.cc:158: // Avoid overflow when adding to current time.
On 2012/09/14 03:27:28, gavinp wrote:
> On 2012/09/13 22:44:07, rvargas wrote:
> > On 2012/09/13 04:45:43, gavinp wrote:
> > > Won't TimeToInt function deal gracefully with overflow? If that behaviour
is
> > > undesirable, why? And why is an interval of 10 years - (1 to 3) days a
> better
> > > overflow value?
> > 
> > freshness can be kint64max, which overflows to a negative time before
reaching
> > TimeToInt()
> 
> This is getting into crazy Nit territory, since 10 years (minus between 1 and
3
> days) is probably fine for this short lived experiment. But I'll share my nit
> for posterity:
> 
> OK... Wow. I just saw how http_response_headers.cc uses
> TimeDelta::FromMicroseconds(kint64max). Interesting. That probably should
switch
> to using TimeDelta::Max(), which just happens to be the same thing...
> 
> So max ints can be scary, but 10 years is a weird magic number. How about
fixing
> it like so:
> 
> if (TimeDelta::Max() - response->response_time > freshness)
>   return TimeToInt(TimeDelta::Max());
> return TimeToInt(response->response_time + freshness);

That seems like a more convoluted way to deal with it... what is exaclty a
TimeDelta - Time ?.

I think that the current version (while using a totally arbitrary time limit) is
simpler and more direct.

http://codereview.chromium.org/10909136/diff/1/net/http/infinite_cache.cc#new...
net/http/infinite_cache.cc:237: struct InfiniteCacheTransaction::ResourceData {
On 2012/09/14 03:27:28, gavinp wrote:
> On 2012/09/13 22:44:07, rvargas wrote:
> > On 2012/09/13 04:45:43, gavinp wrote:
> > > Nit: Isn't this rather than information about a resource, information
about
> a
> > > transaction?
> > 
> > No in that details (and actually also key) refer to the particular resource
> that
> > a transaction is trying to fetch. Or at least that's the bulk of the info
> (with
> > a small overloading of a couple of flags).
> 
> It's constructed once per transaction, and sent to the other thread from
> ...Transaction::Finish(), and in Worker::Process() we update the stats from
the
> information we learned in the transaction. I saw it as a record of a
> transaction, since ResourceData only gains information about prior resources
> after it's already been filled in in ...Transaction methods, and sent down..

Sure... the way to get information about resources is through transactions.
Still, this is meant to represent the information stored by the "infinite
cache", AKA, stored resources.

http://codereview.chromium.org/10909136/diff/1/net/http/infinite_cache.cc#new...
net/http/infinite_cache.cc:471: for (KeyMap::iterator i = map_.begin(); i !=
map_.end();) {
On 2012/09/14 03:27:28, gavinp wrote:
> On 2012/09/13 22:44:07, rvargas wrote:
> > On 2012/09/13 04:45:43, gavinp wrote:
> > > Deletion mid iteration is kind of scary. It looks like you got it right
> here,
> > > but why not store the list of to-delete items in a std::stack or
something,
> > and
> > > delete them all after?
> > 
> > We may be deleting basically the whole list... a lot of objects. Do we want
to
> > take the memory hit?
> 
> 40 megabytes/sizeof(Details) * sizeof(void*) ~= 5 megabytes, allocated and
then
> deallocated in less than 1ms?

So you mean a set of iterators... That's scary. I still prefer the current
version better.

Powered by Google App Engine
This is Rietveld 408576698