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

Issue 887973003: Avoid lossy time stamp conversions when caching metadata. (Closed)

Created:
5 years, 10 months ago by Yang
Modified:
5 years, 10 months ago
CC:
cbentzel+watch_chromium.org, chromium-reviews, darin-cc_chromium.org, gavinp+disk_chromium.org, jam
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Avoid lossy time stamp conversions when caching metadata. base::Time uses int64, but blink time stamps use double. Blink Resource response time stamps are converted from base::Time. When storing Resource metadata to the HTTP cache, that double time stamp is converted back to base::Time. This conversion is lossy and causes metadata to not being cached due to time stamp mismatch. The fix is not to convert the time stamp back to base::Time, and do the comparison in double instead. R=gavinp@chromium.org, jochen@chromium.org BUG=chromium:453298 Committed: https://crrev.com/9222efb0a3410e4c8b2ab1072027b66262dfb594 Cr-Commit-Position: refs/heads/master@{#313922}

Patch Set 1 #

Patch Set 2 : fix unit tests #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+21 lines, -27 lines) Patch
M content/browser/renderer_host/render_message_filter.cc View 1 1 chunk +1 line, -4 lines 0 comments Download
M net/http/http_cache.h View 1 chunk +1 line, -1 line 1 comment Download
M net/http/http_cache.cc View 4 chunks +9 lines, -6 lines 0 comments Download
M net/http/http_cache_unittest.cc View 1 3 chunks +10 lines, -16 lines 0 comments Download

Messages

Total messages: 12 (2 generated)
Yang
5 years, 10 months ago (2015-01-30 09:45:08 UTC) #1
jochen (gone - plz use gerrit)
lgtm
5 years, 10 months ago (2015-01-30 14:38:35 UTC) #2
gavinp
lgtm. I'm a bit anxious about comparing doubles for equality, but this seems to be ...
5 years, 10 months ago (2015-01-30 15:53:50 UTC) #3
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/887973003/20001
5 years, 10 months ago (2015-01-30 16:15:45 UTC) #5
commit-bot: I haz the power
Committed patchset #2 (id:20001)
5 years, 10 months ago (2015-01-30 16:19:33 UTC) #6
commit-bot: I haz the power
Patchset 2 (id:??) landed as https://crrev.com/9222efb0a3410e4c8b2ab1072027b66262dfb594 Cr-Commit-Position: refs/heads/master@{#313922}
5 years, 10 months ago (2015-01-30 16:22:17 UTC) #7
rvargas (doing something else)
https://codereview.chromium.org/887973003/diff/20001/net/http/http_cache.h File net/http/http_cache.h (right): https://codereview.chromium.org/887973003/diff/20001/net/http/http_cache.h#newcode181 net/http/http_cache.h:181: double expected_response_time, Isn't there another way to fix this? ...
5 years, 10 months ago (2015-02-05 20:23:44 UTC) #9
Yang
On 2015/02/05 20:23:44, rvargas wrote: > https://codereview.chromium.org/887973003/diff/20001/net/http/http_cache.h > File net/http/http_cache.h (right): > > https://codereview.chromium.org/887973003/diff/20001/net/http/http_cache.h#newcode181 > ...
5 years, 10 months ago (2015-02-05 21:12:40 UTC) #10
Yang
On 2015/02/05 21:12:40, Yang wrote: > On 2015/02/05 20:23:44, rvargas wrote: > > https://codereview.chromium.org/887973003/diff/20001/net/http/http_cache.h > ...
5 years, 10 months ago (2015-02-05 21:14:11 UTC) #11
rvargas (doing something else)
5 years, 10 months ago (2015-02-05 22:32:29 UTC) #12
Message was sent while issue was closed.
On 2015/02/05 21:14:11, Yang wrote:
> On 2015/02/05 21:12:40, Yang wrote:
> > On 2015/02/05 20:23:44, rvargas wrote:
> > > https://codereview.chromium.org/887973003/diff/20001/net/http/http_cache.h
> > > File net/http/http_cache.h (right):
> > > 
> > >
> >
>
https://codereview.chromium.org/887973003/diff/20001/net/http/http_cache.h#ne...
> > > net/http/http_cache.h:181: double expected_response_time,
> > > Isn't there another way to fix this?
> > > 
> > > This code is not really aware of blink types... it is written with
chromium
> > base
> > > types so having time expressed by a double is completely unnatural.
> > > 
> > > Besides, int64 has a higher resolution than double so you are choosing the
> > > lossiest of the two types.
> > > 
> > > Doesn't seem right!
> > 
> > I agree that this is not optimal. However, this does fix a very real bug.
The
> > higher resolution of int64 has already been lost when the blink resource was
> > created. Given that RenderMessageFilter::OnCacheableMetadataAvailable takes
a
> > double time stamp as argument, I haven't made the issue much worse by
allowing
> > double time stamp in Chromium. Converting that double time stamp back to
int64
> > is definitely the wrong thing to do, so repeating the (deterministically)
> lossy
> > conversion before time stamp comparison seems the only reasonable fix. The
> other
> > clean alternative I see is to refactor all of blink to use int64 instead of
> > double for time stamps, and there would be a ton of places to change. I
myself
> > am far from being familiar enough with blink's code base to attempt a big
> > refactoring like this.
> 
> Of course I could also convert the time stamp from int64 to double and back to
> int64 to guarantee that potentially lossy conversion has been taken into
> account, but that sounds even worse.

The problem is that this code is now inconsistent.
HttpResponseInfo::response_time is a base::Time, and that is the value that the 
API is using to identify a change in the resource. If the consumer decides to
store that value in a variable that doesn't provide enough resolution before
attempting to use WriteMetadata it is not really a problem with the API but with
the consumer (yes, I totally understand that it is a real bug). The correct fix
is not to have an API that in one place provides a base::Time and in another
expects a double for the "same" value. This may be the easiest fix, but not the
right one.

IMO, The IPC message should not be using a double.

Powered by Google App Engine
This is Rietveld 408576698