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

Side by Side Diff: chrome/browser/net/predictor.cc

Issue 1967663002: Effectively disable the predictor's DNS queue for an experiment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add android test config (trybots previous) Created 4 years, 7 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | testing/variations/fieldtrial_testing_config_android.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/net/predictor.h" 5 #include "chrome/browser/net/predictor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <set> 9 #include <set>
10 #include <sstream> 10 #include <sstream>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/containers/mru_cache.h" 14 #include "base/containers/mru_cache.h"
15 #include "base/feature_list.h"
15 #include "base/location.h" 16 #include "base/location.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/macros.h" 18 #include "base/macros.h"
18 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
19 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
20 #include "base/stl_util.h" 21 #include "base/stl_util.h"
21 #include "base/strings/string_split.h" 22 #include "base/strings/string_split.h"
22 #include "base/strings/string_util.h" 23 #include "base/strings/string_util.h"
23 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
24 #include "base/synchronization/waitable_event.h" 25 #include "base/synchronization/waitable_event.h"
(...skipping 24 matching lines...) Expand all
49 #include "net/proxy/proxy_service.h" 50 #include "net/proxy/proxy_service.h"
50 #include "net/ssl/ssl_config_service.h" 51 #include "net/ssl/ssl_config_service.h"
51 #include "net/url_request/url_request_context.h" 52 #include "net/url_request/url_request_context.h"
52 #include "net/url_request/url_request_context_getter.h" 53 #include "net/url_request/url_request_context_getter.h"
53 54
54 using base::TimeDelta; 55 using base::TimeDelta;
55 using content::BrowserThread; 56 using content::BrowserThread;
56 57
57 namespace chrome_browser_net { 58 namespace chrome_browser_net {
58 59
60 namespace {
61 const base::Feature kDisablePredictorDNSQueue {
62 "DisablePredictorDNSQueue", base::FEATURE_DISABLED_BY_DEFAULT};
Alexei Svitkine (slow) 2016/05/10 19:23:04 I think this is confusing because you have a featu
Charlie Harrison 2016/05/10 20:42:14 Thanks for the suggestion. Done.
63 }
64
59 // static 65 // static
60 const int Predictor::kPredictorReferrerVersion = 2; 66 const int Predictor::kPredictorReferrerVersion = 2;
61 const double Predictor::kPreconnectWorthyExpectedValue = 0.8; 67 const double Predictor::kPreconnectWorthyExpectedValue = 0.8;
62 const double Predictor::kDNSPreresolutionWorthyExpectedValue = 0.1; 68 const double Predictor::kDNSPreresolutionWorthyExpectedValue = 0.1;
63 const double Predictor::kDiscardableExpectedValue = 0.05; 69 const double Predictor::kDiscardableExpectedValue = 0.05;
64 // The goal is of trimming is to to reduce the importance (number of expected 70 // The goal is of trimming is to to reduce the importance (number of expected
65 // subresources needed) by a factor of 2 after about 24 hours of uptime. We will 71 // subresources needed) by a factor of 2 after about 24 hours of uptime. We will
66 // trim roughly once-an-hour of uptime. The ratio to use in each trim operation 72 // trim roughly once-an-hour of uptime. The ratio to use in each trim operation
67 // is then the 24th root of 0.5. If a user only surfs for 4 hours a day, then 73 // is then the 24th root of 0.5. If a user only surfs for 4 hours a day, then
68 // after about 6 days they will have halved all their estimates of subresource 74 // after about 6 days they will have halved all their estimates of subresource
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 Results assignees; 425 Results assignees;
420 for (Results::iterator it = results_.begin(); results_.end() != it; ++it) { 426 for (Results::iterator it = results_.begin(); results_.end() != it; ++it) {
421 GURL url(it->first); 427 GURL url(it->first);
422 UrlInfo* info = &it->second; 428 UrlInfo* info = &it->second;
423 DCHECK(info->HasUrl(url)); 429 DCHECK(info->HasUrl(url));
424 if (info->is_assigned()) { 430 if (info->is_assigned()) {
425 info->SetPendingDeleteState(); 431 info->SetPendingDeleteState();
426 assignees[url] = *info; 432 assignees[url] = *info;
427 } 433 }
428 } 434 }
429 DCHECK_LE(assignees.size(), max_concurrent_dns_lookups_); 435 DCHECK(base::FeatureList::IsEnabled(kDisablePredictorDNSQueue) ||
436 assignees.size() <= max_concurrent_dns_lookups_);
430 results_.clear(); 437 results_.clear();
431 // Put back in the names being worked on. 438 // Put back in the names being worked on.
432 for (Results::iterator it = assignees.begin(); assignees.end() != it; ++it) { 439 for (Results::iterator it = assignees.begin(); assignees.end() != it; ++it) {
433 DCHECK(it->second.is_marked_to_delete()); 440 DCHECK(it->second.is_marked_to_delete());
434 results_[it->first] = it->second; 441 results_[it->first] = it->second;
435 } 442 }
436 } 443 }
437 444
438 // Overloaded Resolve() to take a vector of names. 445 // Overloaded Resolve() to take a vector of names.
439 void Predictor::ResolveList(const UrlList& urls, 446 void Predictor::ResolveList(const UrlList& urls,
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 1055
1049 info->SetQueuedState(motivation); 1056 info->SetQueuedState(motivation);
1050 work_queue_.Push(url, motivation); 1057 work_queue_.Push(url, motivation);
1051 1058
1052 StartSomeQueuedResolutions(); 1059 StartSomeQueuedResolutions();
1053 return info; 1060 return info;
1054 } 1061 }
1055 1062
1056 bool Predictor::CongestionControlPerformed(UrlInfo* info) { 1063 bool Predictor::CongestionControlPerformed(UrlInfo* info) {
1057 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1064 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1065 DCHECK(!base::FeatureList::IsEnabled(kDisablePredictorDNSQueue));
1058 // Note: queue_duration is ONLY valid after we go to assigned state. 1066 // Note: queue_duration is ONLY valid after we go to assigned state.
1059 if (info->queue_duration() < max_dns_queue_delay_) 1067 if (info->queue_duration() < max_dns_queue_delay_)
1060 return false; 1068 return false;
1061 // We need to discard all entries in our queue, as we're keeping them waiting 1069 // We need to discard all entries in our queue, as we're keeping them waiting
1062 // too long. By doing this, we'll have a chance to quickly service urgent 1070 // too long. By doing this, we'll have a chance to quickly service urgent
1063 // resolutions, and not have a bogged down system. 1071 // resolutions, and not have a bogged down system.
1064 while (true) { 1072 while (true) {
1065 info->RemoveFromQueue(); 1073 info->RemoveFromQueue();
1066 if (work_queue_.IsEmpty()) 1074 if (work_queue_.IsEmpty())
1067 break; 1075 break;
1068 info = &results_[work_queue_.Pop()]; 1076 info = &results_[work_queue_.Pop()];
1069 info->SetAssignedState(); 1077 info->SetAssignedState();
1070 } 1078 }
1071 return true; 1079 return true;
1072 } 1080 }
1073 1081
1074 void Predictor::StartSomeQueuedResolutions() { 1082 void Predictor::StartSomeQueuedResolutions() {
1075 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1083 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1076 1084
1085 // If the queue is disabled, just make LookupRequests for all entries.
1086 bool disable_queue = base::FeatureList::IsEnabled(kDisablePredictorDNSQueue);
1077 while (!work_queue_.IsEmpty() && 1087 while (!work_queue_.IsEmpty() &&
1078 pending_lookups_.size() < max_concurrent_dns_lookups_) { 1088 (disable_queue ||
1089 pending_lookups_.size() < max_concurrent_dns_lookups_)) {
1079 const GURL url(work_queue_.Pop()); 1090 const GURL url(work_queue_.Pop());
1080 UrlInfo* info = &results_[url]; 1091 UrlInfo* info = &results_[url];
1081 DCHECK(info->HasUrl(url)); 1092 DCHECK(info->HasUrl(url));
1082 info->SetAssignedState(); 1093 info->SetAssignedState();
1083 1094
1084 if (CongestionControlPerformed(info)) { 1095 if (!disable_queue && CongestionControlPerformed(info)) {
1085 DCHECK(work_queue_.IsEmpty()); 1096 DCHECK(work_queue_.IsEmpty());
1086 return; 1097 return;
1087 } 1098 }
1088 1099
1089 LookupRequest* request = new LookupRequest(this, host_resolver_, url); 1100 LookupRequest* request = new LookupRequest(this, host_resolver_, url);
1090 1101
1091 int status = request->Start(); 1102 int status = request->Start();
1092 if (status == net::ERR_IO_PENDING) { 1103 if (status == net::ERR_IO_PENDING) {
1093 // Will complete asynchronously. 1104 // Will complete asynchronously.
1094 pending_lookups_.insert(request); 1105 pending_lookups_.insert(request);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 } 1315 }
1305 1316
1306 void SimplePredictor::ShutdownOnUIThread() { 1317 void SimplePredictor::ShutdownOnUIThread() {
1307 SetShutdown(true); 1318 SetShutdown(true);
1308 } 1319 }
1309 1320
1310 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } 1321 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; }
1311 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } 1322 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; }
1312 1323
1313 } // namespace chrome_browser_net 1324 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « no previous file | testing/variations/fieldtrial_testing_config_android.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698