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

Issue 232003002: Ignore disk cache for concurrent byte range requests to a single resource, to prevent stalling. (Closed)

Created:
6 years, 8 months ago by rileya (GONE FROM CHROMIUM)
Modified:
6 years, 3 months ago
CC:
chromium-reviews, cbentzel+watch_chromium.org, gavinp+disk_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Visibility:
Public.

Description

Ignore disk cache for concurrent byte range requests to a single resource, to prevent stalling. Currently the single writer/multiple reader lock implemented by the http cache results in stalling when multiple byte range requests are made for the same resource. This is most notable in the case of video streaming, where attempting to play back a single video resource in multiple places will result in all but one stalling until the full download completes. This is a hacky fix, wherein we simply ignore the cache if we see that a given HttpCache::Transaction is operating on a sparse (byte range request) cache entry which is already active and currently being written to. BUG=31014

Patch Set 1 #

Patch Set 2 : Check for range requests rather than CouldBeSparse() #

Total comments: 2

Patch Set 3 : Add link to new issue #

Patch Set 4 : Alternate fix to avoid race condition. #

Patch Set 5 : Fix comment #

Patch Set 6 : Slightly less intrusive version of PS4 #

Total comments: 7

Patch Set 7 : address comments #

Patch Set 8 : Add unit test, make conditions for activating hack a bit stricter. #

Total comments: 15

Patch Set 9 : Address comments on test #

Unified diffs Side-by-side diffs Delta from patch set Stats (+61 lines, -1 line) Patch
M net/http/http_cache_transaction.cc View 1 2 3 4 5 6 7 1 chunk +29 lines, -1 line 0 comments Download
M net/http/http_cache_unittest.cc View 1 2 3 4 5 6 7 8 1 chunk +32 lines, -0 lines 0 comments Download

Messages

Total messages: 18 (0 generated)
rileya (GONE FROM CHROMIUM)
Hacky fix for good 'ol crbug.com/31014 This ignores the cache for byte range requests if ...
6 years, 8 months ago (2014-04-09 21:50:35 UTC) #1
rvargas (doing something else)
lgtm. We have to see what happens in practice because we may get bug reports ...
6 years, 8 months ago (2014-04-09 23:56:24 UTC) #2
rvargas (doing something else)
On 2014/04/09 23:56:24, rvargas wrote: > lgtm. > > We have to see what happens ...
6 years, 8 months ago (2014-04-10 00:02:02 UTC) #3
rileya (GONE FROM CHROMIUM)
Adjusted to check if this Transaction is a range request and the writer on the ...
6 years, 8 months ago (2014-04-10 00:12:23 UTC) #4
scherkus (not reviewing)
What's our testing story here? It seems like we might be able to write a ...
6 years, 8 months ago (2014-04-10 18:26:06 UTC) #5
rileya (GONE FROM CHROMIUM)
On 2014/04/10 18:26:06, scherkus wrote: > What's our testing story here? I was wondering the ...
6 years, 8 months ago (2014-04-10 19:24:51 UTC) #6
rvargas (doing something else)
That looks better. As for a test, you should look at TEST(HttpCache, SimpleGET_ManyReaders) for inspiration. ...
6 years, 8 months ago (2014-04-10 21:40:04 UTC) #7
rileya (GONE FROM CHROMIUM)
The original patch actually had a potential race, since it checked for an active cache ...
6 years, 8 months ago (2014-04-14 19:38:28 UTC) #8
rvargas (doing something else)
On 2014/04/14 19:38:28, rileya wrote: > The original patch actually had a potential race, since ...
6 years, 8 months ago (2014-04-15 15:55:07 UTC) #9
rileya (GONE FROM CHROMIUM)
Unfortunately it looks like the fix from PS3 fails ~20% of the time in a ...
6 years, 8 months ago (2014-04-15 17:08:42 UTC) #10
rileya1
PS6 still does the same thing as PS4 but confines the hack to one spot.
6 years, 8 months ago (2014-04-15 17:39:52 UTC) #11
rvargas (doing something else)
https://codereview.chromium.org/232003002/diff/110001/net/http/http_cache_transaction.cc File net/http/http_cache_transaction.cc (right): https://codereview.chromium.org/232003002/diff/110001/net/http/http_cache_transaction.cc#newcode1218 net/http/http_cache_transaction.cc:1218: if (partial_ && result == net::ERR_IO_PENDING) { Why giving ...
6 years, 8 months ago (2014-04-22 00:44:30 UTC) #12
rileya (GONE FROM CHROMIUM)
I'm still having some issues with redirects, but it appears to be an unrelated issue, ...
6 years, 8 months ago (2014-04-23 17:45:05 UTC) #13
rvargas (doing something else)
I guess it's time for net unit tests. https://codereview.chromium.org/232003002/diff/110001/net/http/http_cache_transaction.cc File net/http/http_cache_transaction.cc (right): https://codereview.chromium.org/232003002/diff/110001/net/http/http_cache_transaction.cc#newcode1218 net/http/http_cache_transaction.cc:1218: if ...
6 years, 8 months ago (2014-04-23 18:56:54 UTC) #14
rileya1
Looking into this again. I made the check a little stricter for triggering the hack, ...
6 years, 6 months ago (2014-05-29 00:24:15 UTC) #15
rvargas (doing something else)
https://codereview.chromium.org/232003002/diff/150001/net/http/http_cache_transaction.cc File net/http/http_cache_transaction.cc (right): https://codereview.chromium.org/232003002/diff/150001/net/http/http_cache_transaction.cc#newcode1219 net/http/http_cache_transaction.cc:1219: (mode() & Transaction::WRITE && !new_entry_->readers.empty()))) { You mentioned that ...
6 years, 6 months ago (2014-05-29 19:58:52 UTC) #16
rileya (GONE FROM CHROMIUM)
https://codereview.chromium.org/232003002/diff/150001/net/http/http_cache_transaction.cc File net/http/http_cache_transaction.cc (right): https://codereview.chromium.org/232003002/diff/150001/net/http/http_cache_transaction.cc#newcode1219 net/http/http_cache_transaction.cc:1219: (mode() & Transaction::WRITE && !new_entry_->readers.empty()))) { On 2014/05/29 19:58:52, ...
6 years, 6 months ago (2014-05-29 20:15:02 UTC) #17
rvargas (doing something else)
6 years, 6 months ago (2014-05-29 21:03:49 UTC) #18
https://codereview.chromium.org/232003002/diff/150001/net/http/http_cache_tra...
File net/http/http_cache_transaction.cc (right):

https://codereview.chromium.org/232003002/diff/150001/net/http/http_cache_tra...
net/http/http_cache_transaction.cc:1219: (mode() & Transaction::WRITE &&
!new_entry_->readers.empty()))) {
On 2014/05/29 20:15:03, rileya wrote:
> On 2014/05/29 19:58:52, rvargas wrote:
> > You mentioned that this fixed some small issues. My reaction would be to
> remove
> > the extra check because it seems to be just duplicating the logic that
returns
> > io_pending from AddTransactionToEntry... except in the case of a race where
> the
> > cache is in the process of moving from one transaction to the next. If that
is
> > causing issues, it seems too subtle to handle it by duplicating some logic
> here
> > and it would be better to ask the cache about it. What was the issue?
> 
> It was indeed a problem of racing when moving between transactions in the
> pending queue, when there weren't actually any readers/writers to block the
> transaction (this caused several net_unittests to fail). How would you
recommend
> handling this without duplicating this logic? 

It doesn't seem reasonable (possible?) to ask transactions to be aware of the
state of the cache (ok, ActiveEntry but still) before calling
RemovePendingTransaction. That says to me that the cache must be prepared to
receive that call at any time, and it should handle the case where the
transaction that is going away is the only transaction tied to the entry.

Reading HttpCache::OnProcessPendingQueue it looks like it does everything as
intended... it just deletes the entry if there's no transaction to deal with. So
I guess I would have to see exactly what is failing and why to answer you.

Is it just that unit tests that expect requests to be queued are seeing requests
escaping the lock? If that's the case then the issue would not be
will_process_pending_queue but the fact that the workaround lets regular (not
byte range related) requests trigger the escape.

Powered by Google App Engine
This is Rietveld 408576698