Commit 9eb5df8c authored by Charles Zhao's avatar Charles Zhao Committed by Commit Bot

Tabdiscarder: explore process_types to be scored by tabranker.

This change gives us the ability to explore different process_types to
be scored by TabRanker. We can try
(1) to only discard BACKGROUND tabs. or
(2) to discard BACKGROUND and PROTECTED_BACKGROUND tabs.

Bug: 968391
Change-Id: Idb65c1609ce81aa5c8c3a0b07c8cab1a016384d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1633872Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Commit-Queue: Charles . <charleszhao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665004}
parent ad2f62d6
......@@ -553,12 +553,16 @@ void TabManagerDelegate::SortLifecycleUnitWithTabRanker(
const uint32_t num_of_tab_to_score = GetNumOldestTabsToScoreWithTabRanker();
if (num_of_tab_to_score <= 1)
return;
const ProcessType process_type =
static_cast<ProcessType>(GetProcessTypeToScoreWithTabRanker());
// Put the oldest num_of_tab_to_score lifecycle units into a vector.
LifecycleUnitVector oldest_lifecycle_units;
for (auto it = candidates->rbegin(); it != candidates->rend(); ++it) {
auto& candidate = *it;
if (oldest_lifecycle_units.size() == num_of_tab_to_score ||
candidate.process_type() < ProcessType::BACKGROUND)
candidate.process_type() < process_type)
break;
if (candidate.lifecycle_unit()) {
oldest_lifecycle_units.push_back(candidate.lifecycle_unit());
......@@ -572,7 +576,7 @@ void TabManagerDelegate::SortLifecycleUnitWithTabRanker(
for (auto it = candidates->rbegin(); it != candidates->rend(); ++it) {
const auto& candidate = *it;
if (oldest_lifecycle_units.empty() ||
candidate.process_type() < ProcessType::BACKGROUND)
candidate.process_type() < process_type)
break;
if (candidate.lifecycle_unit()) {
*it = Candidate(oldest_lifecycle_units.back());
......
......@@ -262,6 +262,11 @@ int GetNumOldestTabsToScoreWithTabRanker() {
std::numeric_limits<int>::max());
}
int GetProcessTypeToScoreWithTabRanker() {
return base::GetFieldTrialParamByFeatureAsInt(
features::kTabRanker, "process_type_of_tabs_to_score_with_TabRanker", 4);
}
int GetNumOldestTabsToLogWithTabRanker() {
return base::GetFieldTrialParamByFeatureAsInt(
features::kTabRanker, "number_of_oldest_tabs_to_log_with_TabRanker", 0);
......
......@@ -267,6 +267,9 @@ GetStaticSiteCharacteristicsDatabaseParams();
// Gets number of oldest tab that should be scored by TabRanker.
int GetNumOldestTabsToScoreWithTabRanker();
// Gets ProcessType of tabs that should be scored by TabRanker.
int GetProcessTypeToScoreWithTabRanker();
// Gets number of oldest tabs that should be logged by TabRanker.
int GetNumOldestTabsToLogWithTabRanker();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment