Commit 4e7e1661 authored by Charles Zhao's avatar Charles Zhao Committed by Commit Bot

remove LogAndMaybeSortLifecycleUnitWithTabRanker.

LogAndMaybeSortLifecycleUnitWithTabRanker is not used and will not be used in any time soon. So remove it from TabManagerDelegate for now.

Bug: 1131349
Change-Id: I614336b9ddfe4758d1a364a39195070dde237a79
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2423800Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarCharles . <charleszhao@chromium.org>
Reviewed-by: default avatarThanh Nguyen <thanhdng@chromium.org>
Reviewed-by: default avatarSébastien Marchand <sebmarchand@chromium.org>
Commit-Queue: Charles . <charleszhao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810475}
parent 1d13ec8c
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/memory/memory_kills_monitor.h" #include "chrome/browser/memory/memory_kills_monitor.h"
#include "chrome/browser/resource_coordinator/lifecycle_unit.h" #include "chrome/browser/resource_coordinator/lifecycle_unit.h"
#include "chrome/browser/resource_coordinator/tab_activity_watcher.h"
#include "chrome/browser/resource_coordinator/tab_lifecycle_unit_external.h" #include "chrome/browser/resource_coordinator/tab_lifecycle_unit_external.h"
#include "chrome/browser/resource_coordinator/tab_manager_stats_collector.h" #include "chrome/browser/resource_coordinator/tab_manager_stats_collector.h"
#include "chrome/browser/resource_coordinator/utils.h" #include "chrome/browser/resource_coordinator/utils.h"
...@@ -527,46 +526,6 @@ TabManagerDelegate::GetSortedCandidates( ...@@ -527,46 +526,6 @@ TabManagerDelegate::GetSortedCandidates(
return candidates; return candidates;
} }
void TabManagerDelegate::LogAndMaybeSortLifecycleUnitWithTabRanker(
std::vector<Candidate>* candidates,
LifecycleUnitSorter sorter) {
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() < process_type)
break;
if (candidate.lifecycle_unit()) {
oldest_lifecycle_units.push_back(candidate.lifecycle_unit());
}
}
// log and possibly Re-sort them with TabRanker.
std::move(sorter).Run(&oldest_lifecycle_units);
if (base::FeatureList::IsEnabled(features::kTabRanker)) {
// Put the sorted lifecycle units back to their original vacancies.
for (auto it = candidates->rbegin(); it != candidates->rend(); ++it) {
const auto& candidate = *it;
if (oldest_lifecycle_units.empty() ||
candidate.process_type() < process_type)
break;
if (candidate.lifecycle_unit()) {
*it = Candidate(oldest_lifecycle_units.back());
oldest_lifecycle_units.pop_back();
}
}
}
}
bool TabManagerDelegate::IsRecentlyKilledArcProcess( bool TabManagerDelegate::IsRecentlyKilledArcProcess(
const std::string& process_name, const std::string& process_name,
const TimeTicks& now) { const TimeTicks& now) {
...@@ -617,14 +576,6 @@ void TabManagerDelegate::LowMemoryKillImpl( ...@@ -617,14 +576,6 @@ void TabManagerDelegate::LowMemoryKillImpl(
std::vector<Candidate> candidates = std::vector<Candidate> candidates =
GetSortedCandidates(GetLifecycleUnits(), arc_processes); GetSortedCandidates(GetLifecycleUnits(), arc_processes);
// Log and Re-order oldest N LifecycleUnits if TabRanker is enabled; otherwise
// only log N LifecycleUnits and the candidates will be unchanged.
LogAndMaybeSortLifecycleUnitWithTabRanker(
&candidates,
base::BindOnce(
&TabActivityWatcher::LogAndMaybeSortLifecycleUnitWithTabRanker,
base::Unretained(TabActivityWatcher::GetInstance())));
// TODO(semenzato): decide if TargetMemoryToFreeKB is doing real // TODO(semenzato): decide if TargetMemoryToFreeKB is doing real
// I/O and if it is, move to I/O thread (crbug.com/778703). // I/O and if it is, move to I/O thread (crbug.com/778703).
int target_memory_to_free_kb = 0; int target_memory_to_free_kb = 0;
......
...@@ -147,18 +147,6 @@ class TabManagerDelegate : public wm::ActivationChangeObserver, ...@@ -147,18 +147,6 @@ class TabManagerDelegate : public wm::ActivationChangeObserver,
const LifecycleUnitVector& lifecycle_units, const LifecycleUnitVector& lifecycle_units,
const OptionalArcProcessList& arc_processes); const OptionalArcProcessList& arc_processes);
// This is only used for TabRanker experiment for now.
// If TabRanker is enabled, this will take the last N lifecycle units in the
// |candidates|; sort these lifecycle units based on the TabRanker order; and
// put these sorted lifecycle unit back to the vacancies of these lifecycle
// units in the |candidates|.
// If TabRanker is disabled, this will log the TabMetrics of these lifecycle
// units.
// All apps in the |candidates| will not be influenced.
static void LogAndMaybeSortLifecycleUnitWithTabRanker(
std::vector<Candidate>* candidates,
LifecycleUnitSorter sorter);
// Returns the LifecycleUnits in TabManager. Virtual for unit tests. // Returns the LifecycleUnits in TabManager. Virtual for unit tests.
virtual LifecycleUnitVector GetLifecycleUnits(); virtual LifecycleUnitVector GetLifecycleUnits();
......
...@@ -106,74 +106,6 @@ TEST_F(TabManagerDelegateTest, CandidatesSortedWithFocusedAppAndTab) { ...@@ -106,74 +106,6 @@ TEST_F(TabManagerDelegateTest, CandidatesSortedWithFocusedAppAndTab) {
EXPECT_EQ("focused", candidates[1].app()->process_name()); EXPECT_EQ("focused", candidates[1].app()->process_name());
} }
// Test to make sure old process types are active when TabRanker experiment
// is turned on.
TEST_F(TabManagerDelegateTest, SortLifecycleUnitWithTabRanker) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeatureWithParameters(
features::kTabRanker,
{{"number_of_oldest_tabs_to_score_with_TabRanker", "20"},
{"process_type_of_tabs_to_score_with_TabRanker", "4"}});
std::vector<arc::ArcProcess> arc_processes;
arc_processes.emplace_back(1, 10, "focused", arc::mojom::ProcessState::TOP,
kIsFocused, 99);
arc_processes.emplace_back(2, 20, "visible1", arc::mojom::ProcessState::TOP,
kNotFocused, 89);
arc_processes.emplace_back(
3, 30, "service", arc::mojom::ProcessState::SERVICE, kNotFocused, 95);
TestLifecycleUnit tab1(
base::TimeTicks() + base::TimeDelta::FromMilliseconds(100), 4);
TestLifecycleUnit tab2(
base::TimeTicks() + base::TimeDelta::FromMilliseconds(90), 5, false);
TestLifecycleUnit tab3(
base::TimeTicks() + base::TimeDelta::FromMilliseconds(80), 6);
LifecycleUnitVector lifecycle_units{&tab1, &tab2, &tab3};
TabManagerDelegate::OptionalArcProcessList opt_arc_processes(
std::move(arc_processes));
std::vector<TabManagerDelegate::Candidate> candidates;
candidates = TabManagerDelegate::GetSortedCandidates(lifecycle_units,
opt_arc_processes);
// Verify the original order.
ASSERT_EQ(6U, candidates.size());
EXPECT_EQ("focused", candidates[0].app()->process_name());
EXPECT_EQ(ProcessType::FOCUSED_APP, candidates[0].process_type());
EXPECT_EQ(&tab2, candidates[1].lifecycle_unit());
EXPECT_EQ(ProcessType::PROTECTED_BACKGROUND, candidates[1].process_type());
EXPECT_EQ("visible1", candidates[2].app()->process_name());
EXPECT_EQ(ProcessType::PROTECTED_BACKGROUND, candidates[2].process_type());
EXPECT_EQ(&tab1, candidates[3].lifecycle_unit());
EXPECT_EQ(ProcessType::BACKGROUND, candidates[3].process_type());
EXPECT_EQ("service", candidates[4].app()->process_name());
EXPECT_EQ(ProcessType::BACKGROUND, candidates[4].process_type());
EXPECT_EQ(&tab3, candidates[5].lifecycle_unit());
EXPECT_EQ(ProcessType::BACKGROUND, candidates[5].process_type());
auto oldest_first = [](LifecycleUnitVector* lifecycle_units) {
std::sort(lifecycle_units->begin(), lifecycle_units->end(),
[](LifecycleUnit* a, LifecycleUnit* b) {
return a->GetLastFocusedTime() < b->GetLastFocusedTime();
});
};
// Verify the re-ranked order.
TabManagerDelegate::LogAndMaybeSortLifecycleUnitWithTabRanker(
&candidates, base::BindOnce(oldest_first));
EXPECT_EQ("focused", candidates[0].app()->process_name());
EXPECT_EQ(&tab2, candidates[1].lifecycle_unit());
EXPECT_EQ("visible1", candidates[2].app()->process_name());
EXPECT_EQ(&tab3, candidates[3].lifecycle_unit());
EXPECT_EQ("service", candidates[4].app()->process_name());
EXPECT_EQ(&tab1, candidates[5].lifecycle_unit());
}
class MockTabManagerDelegate : public TabManagerDelegate { class MockTabManagerDelegate : public TabManagerDelegate {
public: public:
MockTabManagerDelegate() MockTabManagerDelegate()
......
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