OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/dns_global.h" | 5 #include "chrome/browser/net/dns_global.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/singleton.h" | 10 #include "base/singleton.h" |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 // Methods for the helper class that is used to startup and teardown the whole | 536 // Methods for the helper class that is used to startup and teardown the whole |
537 // DNS prefetch system. | 537 // DNS prefetch system. |
538 | 538 |
539 DnsGlobalInit::DnsGlobalInit(PrefService* user_prefs, | 539 DnsGlobalInit::DnsGlobalInit(PrefService* user_prefs, |
540 PrefService* local_state) { | 540 PrefService* local_state) { |
541 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 541 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
542 // Set up a field trial to see what disabling DNS pre-resolution does to | 542 // Set up a field trial to see what disabling DNS pre-resolution does to |
543 // latency of page loads. | 543 // latency of page loads. |
544 FieldTrial::Probability kDivisor = 100; | 544 FieldTrial::Probability kDivisor = 100; |
545 // For each option (i.e., non-default), we have a fixed probability. | 545 // For each option (i.e., non-default), we have a fixed probability. |
546 FieldTrial::Probability kProbabilityPerGroup = 3; // 3% probability. | 546 FieldTrial::Probability kProbabilityPerGroup = 5; // 5% probability. |
547 | 547 |
548 trial_ = new FieldTrial("DnsImpact", kDivisor); | 548 trial_ = new FieldTrial("DnsImpact", kDivisor); |
549 | 549 |
550 // First option is to disable prefetching completely. | 550 // First option is to disable prefetching completely. |
551 int disabled_prefetch = trial_->AppendGroup("_disabled_prefetch", | 551 int disabled_prefetch = trial_->AppendGroup("_disabled_prefetch", |
552 kProbabilityPerGroup); | 552 kProbabilityPerGroup); |
| 553 |
| 554 |
| 555 // We're running two experiments at the same time. The first set of trials |
| 556 // modulates the delay-time until we declare a congestion event (and purge |
| 557 // our queue). The second modulates the number of concurrent resolutions |
| 558 // we do at any time. Users are in exactly one trial (or the default) during |
| 559 // any one run, and hence only one experiment at a time. |
| 560 // Experiment 1: |
553 // Set congestion detection at 250, 500, or 750ms, rather than the 1 second | 561 // Set congestion detection at 250, 500, or 750ms, rather than the 1 second |
554 // default. | 562 // default. |
555 int max_250ms_prefetch = trial_->AppendGroup("_max_250ms_queue_prefetch", | 563 int max_250ms_prefetch = trial_->AppendGroup("_max_250ms_queue_prefetch", |
556 kProbabilityPerGroup); | 564 kProbabilityPerGroup); |
557 int max_500ms_prefetch = trial_->AppendGroup("_max_500ms_queue_prefetch", | 565 int max_500ms_prefetch = trial_->AppendGroup("_max_500ms_queue_prefetch", |
558 kProbabilityPerGroup); | 566 kProbabilityPerGroup); |
559 int max_750ms_prefetch = trial_->AppendGroup("_max_750ms_queue_prefetch", | 567 int max_750ms_prefetch = trial_->AppendGroup("_max_750ms_queue_prefetch", |
560 kProbabilityPerGroup); | 568 kProbabilityPerGroup); |
561 // Set congestion detection at 2 seconds instead of the 1 second default. | 569 // Set congestion detection at 2 seconds instead of the 1 second default. |
562 int max_2s_prefetch = trial_->AppendGroup("_max_2s_queue_prefetch", | 570 int max_2s_prefetch = trial_->AppendGroup("_max_2s_queue_prefetch", |
563 kProbabilityPerGroup); | 571 kProbabilityPerGroup); |
| 572 // Experiment 2: |
| 573 // Set max simultaneous resoultions to 2, 4, or 6, and scale the congestion |
| 574 // limit proportionally (so we don't impact average probability of asserting |
| 575 // congesion very much). |
| 576 int max_2_concurrent_prefetch = trial_->AppendGroup( |
| 577 "_max_2 concurrent_prefetch", kProbabilityPerGroup); |
| 578 int max_4_concurrent_prefetch = trial_->AppendGroup( |
| 579 "_max_4 concurrent_prefetch", kProbabilityPerGroup); |
| 580 int max_6_concurrent_prefetch = trial_->AppendGroup( |
| 581 "_max_6 concurrent_prefetch", kProbabilityPerGroup); |
564 | 582 |
565 trial_->AppendGroup("_default_enabled_prefetch", | 583 trial_->AppendGroup("_default_enabled_prefetch", |
566 FieldTrial::kAllRemainingProbability); | 584 FieldTrial::kAllRemainingProbability); |
567 | 585 |
568 // We will register the incognito observer regardless of whether prefetching | 586 // We will register the incognito observer regardless of whether prefetching |
569 // is enabled, as it is also used to clear the host cache. | 587 // is enabled, as it is also used to clear the host cache. |
570 Singleton<OffTheRecordObserver>::get()->Register(); | 588 Singleton<OffTheRecordObserver>::get()->Register(); |
571 | 589 |
572 if (trial_->group() != disabled_prefetch) { | 590 if (trial_->group() != disabled_prefetch) { |
573 // Initialize the DNS prefetch system. | 591 // Initialize the DNS prefetch system. |
574 | |
575 size_t max_concurrent = kMaxPrefetchConcurrentLookups; | 592 size_t max_concurrent = kMaxPrefetchConcurrentLookups; |
576 | |
577 int max_queueing_delay_ms = kMaxPrefetchQueueingDelayMs; | 593 int max_queueing_delay_ms = kMaxPrefetchQueueingDelayMs; |
578 | 594 |
579 if (trial_->group() == max_250ms_prefetch) | 595 if (trial_->group() == max_250ms_prefetch) |
580 max_queueing_delay_ms = 250; | 596 max_queueing_delay_ms = 250; |
581 else if (trial_->group() == max_500ms_prefetch) | 597 else if (trial_->group() == max_500ms_prefetch) |
582 max_queueing_delay_ms = 500; | 598 max_queueing_delay_ms = 500; |
583 else if (trial_->group() == max_750ms_prefetch) | 599 else if (trial_->group() == max_750ms_prefetch) |
584 max_queueing_delay_ms = 750; | 600 max_queueing_delay_ms = 750; |
585 else if (trial_->group() == max_2s_prefetch) | 601 else if (trial_->group() == max_2s_prefetch) |
586 max_queueing_delay_ms = 2000; | 602 max_queueing_delay_ms = 2000; |
| 603 if (trial_->group() == max_2_concurrent_prefetch) |
| 604 max_concurrent = 2; |
| 605 else if (trial_->group() == max_4_concurrent_prefetch) |
| 606 max_concurrent = 4; |
| 607 else if (trial_->group() == max_6_concurrent_prefetch) |
| 608 max_concurrent = 6; |
| 609 // Scale acceptable delay so we don't cause congestion limits to fire as |
| 610 // we modulate max_concurrent (*if* we are modulating it at all). |
| 611 max_queueing_delay_ms = (kMaxPrefetchQueueingDelayMs * |
| 612 kMaxPrefetchConcurrentLookups) / max_concurrent; |
587 | 613 |
588 TimeDelta max_queueing_delay( | 614 TimeDelta max_queueing_delay( |
589 TimeDelta::FromMilliseconds(max_queueing_delay_ms)); | 615 TimeDelta::FromMilliseconds(max_queueing_delay_ms)); |
590 | 616 |
591 DCHECK(!dns_master); | 617 DCHECK(!dns_master); |
592 InitDnsPrefetch(max_queueing_delay, max_concurrent, user_prefs, | 618 InitDnsPrefetch(max_queueing_delay, max_concurrent, user_prefs, |
593 local_state); | 619 local_state); |
594 } | 620 } |
595 } | 621 } |
596 | 622 |
597 } // namespace chrome_browser_net | 623 } // namespace chrome_browser_net |
OLD | NEW |