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

Unified Diff: net/http/http_cache_transaction.cc

Issue 1476123002: Bounce all requests off the cache lock after 25ms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mmenke comments Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_cache_transaction.h ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_transaction.cc
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc
index 8c19b9a592bd4fb8d491cfd2e5ea555b218b8082..9ae4da5c42502f1094349f2dcc6bf0fec8f64801 100644
--- a/net/http/http_cache_transaction.cc
+++ b/net/http/http_cache_transaction.cc
@@ -265,7 +265,6 @@ HttpCache::Transaction::Transaction(RequestPriority priority, HttpCache* cache)
done_reading_(false),
vary_mismatch_(false),
couldnt_conditionalize_request_(false),
- bypass_lock_for_test_(false),
fail_conditionalization_for_test_(false),
io_buf_len_(0),
read_offset_(0),
@@ -1167,34 +1166,29 @@ int HttpCache::Transaction::DoAddToEntry() {
entry_lock_waiting_since_ = TimeTicks::Now();
int rv = cache_->AddTransactionToEntry(new_entry_, this);
if (rv == ERR_IO_PENDING) {
- if (bypass_lock_for_test_) {
- OnAddToEntryTimeout(entry_lock_waiting_since_);
- } else {
- int timeout_milliseconds = 20 * 1000;
- if (partial_ && new_entry_->writer &&
- new_entry_->writer->range_requested_) {
- // Quickly timeout and bypass the cache if we're a range request and
- // we're blocked by the reader/writer lock. Doing so eliminates a long
- // running issue, http://crbug.com/31014, where two of the same media
- // resources could not be played back simultaneously due to one locking
- // the cache entry until the entire video was downloaded.
- //
- // Bypassing the cache is not ideal, as we are now ignoring the cache
- // entirely for all range requests to a resource beyond the first. This
- // is however a much more succinct solution than the alternatives, which
- // would require somewhat significant changes to the http caching logic.
- //
- // Allow some timeout slack for the entry addition to complete in case
- // the writer lock is imminently released; we want to avoid skipping
- // the cache if at all possible. See http://crbug.com/408765
- timeout_milliseconds = 25;
- }
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&HttpCache::Transaction::OnAddToEntryTimeout,
- weak_factory_.GetWeakPtr(), entry_lock_waiting_since_),
- TimeDelta::FromMilliseconds(timeout_milliseconds));
- }
+ // Quickly timeout and bypass the cache if the blocked by the
+ // reader/writer lock. Metrics indicate that only 0.89% of requests are
+ // blocked on the cache lock for longer than 25ms.
+ //
+ // Bypassing the cache is not ideal, as we are now ignoring the cache
+ // entirely for requests which hit a resource in
+ // parallel. https://crbug.com/472740 tracks a better design for the
+ // system.
+ //
+ // In the meantime, having a cache lock causes numerous priority inversion
+ // problems and deadlocks, so it is better to ensure the system can make
+ // forward progress. (See https://crbug.com/31014,
+ // https://crbug.com/458620, https://crbug.com/535793, and
+ // https://crbug.com/6697.)
+ //
+ // Allow some timeout slack for the entry addition to complete in case the
+ // writer lock is imminently released; we want to avoid skipping the cache
+ // if at all possible. See http://crbug.com/408765
+ base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&HttpCache::Transaction::OnAddToEntryTimeout,
+ weak_factory_.GetWeakPtr(), entry_lock_waiting_since_),
+ TimeDelta::FromMilliseconds(25));
}
return rv;
}
« no previous file with comments | « net/http/http_cache_transaction.h ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698