Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/memory/tab_manager_delegate_chromeos.h" | 5 #include "chrome/browser/memory/tab_manager_delegate_chromeos.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 default: | 114 default: |
| 115 return os << "NOT_IMPLEMENTED_ERROR"; | 115 return os << "NOT_IMPLEMENTED_ERROR"; |
| 116 } | 116 } |
| 117 return os; | 117 return os; |
| 118 } | 118 } |
| 119 | 119 |
| 120 // TabManagerDelegate::Candidate implementation. | 120 // TabManagerDelegate::Candidate implementation. |
| 121 std::ostream& operator<<( | 121 std::ostream& operator<<( |
| 122 std::ostream& out, const TabManagerDelegate::Candidate& candidate) { | 122 std::ostream& out, const TabManagerDelegate::Candidate& candidate) { |
| 123 if (candidate.app()) { | 123 if (candidate.app()) { |
| 124 out << "app " << candidate.app()->pid() << " (" | 124 const auto& app = candidate.app(); |
|
teravest
2017/05/18 20:11:55
nit: Mind using the type explicitly here? It's not
Yusuke Sato
2017/05/18 20:27:36
Also, const auto& failed git-cl try. FYI.
cylee1
2017/05/18 21:10:30
Done.
| |
| 125 << candidate.app()->process_name() << ")" | 125 out << "app " << app->process_name() << " (" << app->pid() << ")" |
|
Yusuke Sato
2017/05/18 20:24:51
How about moving this to c/b/c/arc/process/arc_pro
cylee1
2017/05/18 21:10:30
Done.
| |
| 126 << ", process_state " << candidate.app()->process_state() | 126 << ", process_state: " << app->process_state() |
|
Yusuke Sato
2017/05/18 20:24:51
Can you stringify the state number?
Yusuke Sato
2017/05/18 20:31:39
nvm, it's already done in the mojo-generated opera
cylee1
2017/05/18 21:10:30
It's already printed like
ProcessState::PERSISTENT
| |
| 127 << ", is_focused " << candidate.app()->is_focused() | 127 << ", is_focused: " << app->is_focused() |
| 128 << ", lastActivityTime " << candidate.app()->last_activity_time(); | 128 << ", last_activity_time: " << app->last_activity_time(); |
|
Yusuke Sato
2017/05/18 20:24:51
Can you also dump packages_ vector?
cylee1
2017/05/18 21:10:30
Done.
| |
| 129 } else if (candidate.tab()) { | 129 } else if (candidate.tab()) { |
| 130 out << "tab " << candidate.tab()->renderer_handle; | 130 const auto& tab = candidate.tab(); |
|
teravest
2017/05/18 20:11:55
nit: Mind using the type explicitly here? It's not
cylee1
2017/05/18 21:10:30
Done.
| |
| 131 out << "tab " << tab->title << " (" << tab->renderer_handle << ")" | |
|
Yusuke Sato
2017/05/18 20:24:52
How did you select the variables to dump? https://
cylee1
2017/05/18 21:10:30
I tried to select most relevant fields from my exp
Yusuke Sato
2017/05/18 21:42:49
Acknowledged.
| |
| 132 << ", oom_score: " << tab->oom_score | |
| 133 << ", is_discarded: " << tab->is_discarded | |
| 134 << ", discard_count: " << tab->discard_count | |
| 135 << ", last_active: " << tab->last_active; | |
| 131 } | 136 } |
| 132 out << ", process_type " << candidate.process_type(); | 137 out << ", process_type " << candidate.process_type(); |
| 133 return out; | 138 return out; |
| 134 } | 139 } |
| 135 | 140 |
| 136 TabManagerDelegate::Candidate& TabManagerDelegate::Candidate::operator=( | 141 TabManagerDelegate::Candidate& TabManagerDelegate::Candidate::operator=( |
| 137 TabManagerDelegate::Candidate&& other) { | 142 TabManagerDelegate::Candidate&& other) { |
| 138 tab_ = other.tab_; | 143 tab_ = other.tab_; |
| 139 app_ = other.app_; | 144 app_ = other.app_; |
| 140 process_type_ = other.process_type_; | 145 process_type_ = other.process_type_; |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 const std::vector<arc::ArcProcess>& arc_processes) { | 589 const std::vector<arc::ArcProcess>& arc_processes) { |
| 585 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 590 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 586 VLOG(2) << "LowMemoryKillImpl"; | 591 VLOG(2) << "LowMemoryKillImpl"; |
| 587 | 592 |
| 588 const std::vector<TabManagerDelegate::Candidate> candidates = | 593 const std::vector<TabManagerDelegate::Candidate> candidates = |
| 589 GetSortedCandidates(tab_list, arc_processes); | 594 GetSortedCandidates(tab_list, arc_processes); |
| 590 | 595 |
| 591 int target_memory_to_free_kb = mem_stat_->TargetMemoryToFreeKB(); | 596 int target_memory_to_free_kb = mem_stat_->TargetMemoryToFreeKB(); |
| 592 const TimeTicks now = TimeTicks::Now(); | 597 const TimeTicks now = TimeTicks::Now(); |
| 593 | 598 |
| 599 MEMORY_LOG(ERROR) << "List of all low memory kill candidates:"; | |
|
Yusuke Sato
2017/05/18 20:24:51
Mention that the list is sorted?
cylee1
2017/05/18 21:10:30
Done.
| |
| 600 for (auto it = candidates.rbegin(); it != candidates.rend(); ++it) { | |
| 601 MEMORY_LOG(ERROR) << *it; | |
| 602 } | |
| 594 // Kill processes until the estimated amount of freed memory is sufficient to | 603 // Kill processes until the estimated amount of freed memory is sufficient to |
| 595 // bring the system memory back to a normal level. | 604 // bring the system memory back to a normal level. |
| 596 // The list is sorted by descending importance, so we go through the list | 605 // The list is sorted by descending importance, so we go through the list |
| 597 // backwards. | 606 // backwards. |
| 598 for (auto it = candidates.rbegin(); it != candidates.rend(); ++it) { | 607 for (auto it = candidates.rbegin(); it != candidates.rend(); ++it) { |
| 599 MEMORY_LOG(ERROR) << "Target memory to free: " << target_memory_to_free_kb | 608 MEMORY_LOG(ERROR) << "Target memory to free: " << target_memory_to_free_kb |
| 600 << " KB"; | 609 << " KB"; |
| 601 if (target_memory_to_free_kb <= 0) | 610 if (target_memory_to_free_kb <= 0) |
| 602 break; | 611 break; |
| 603 // Never kill selected tab, foreground app, and important apps regardless of | 612 // Never kill selected tab, foreground app, and important apps regardless of |
| 604 // whether they're in the active window. Since the user experience would be | 613 // whether they're in the active window. Since the user experience would be |
| 605 // bad. | 614 // bad. |
| 606 ProcessType process_type = it->process_type(); | 615 ProcessType process_type = it->process_type(); |
| 607 if (process_type <= ProcessType::IMPORTANT_APP) { | 616 if (process_type <= ProcessType::IMPORTANT_APP) { |
| 608 MEMORY_LOG(ERROR) << "Skipped killing " << *it; | 617 MEMORY_LOG(ERROR) << "Skipped killing " << *it; |
|
Yusuke Sato
2017/05/18 20:24:52
Using *it inside the second loop might be too spam
cylee1
2017/05/18 21:10:30
Done.
| |
| 609 continue; | 618 continue; |
| 610 } | 619 } |
| 611 if (it->app()) { | 620 if (it->app()) { |
| 612 if (IsRecentlyKilledArcProcess(it->app()->process_name(), now)) { | 621 if (IsRecentlyKilledArcProcess(it->app()->process_name(), now)) { |
| 613 MEMORY_LOG(ERROR) << "Avoided killing " << *it << " too often"; | 622 MEMORY_LOG(ERROR) << "Avoided killing " << *it << " too often"; |
| 614 continue; | 623 continue; |
| 615 } | 624 } |
| 616 int estimated_memory_freed_kb = | 625 int estimated_memory_freed_kb = |
| 617 mem_stat_->EstimatedMemoryFreedKB(it->app()->pid()); | 626 mem_stat_->EstimatedMemoryFreedKB(it->app()->pid()); |
| 618 if (KillArcProcess(it->app()->nspid())) { | 627 if (KillArcProcess(it->app()->nspid())) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 770 priority += priority_increment; | 779 priority += priority_increment; |
| 771 } | 780 } |
| 772 | 781 |
| 773 if (oom_scores_to_change.size()) { | 782 if (oom_scores_to_change.size()) { |
| 774 GetDebugDaemonClient()->SetOomScoreAdj( | 783 GetDebugDaemonClient()->SetOomScoreAdj( |
| 775 oom_scores_to_change, base::Bind(&OnSetOomScoreAdj)); | 784 oom_scores_to_change, base::Bind(&OnSetOomScoreAdj)); |
| 776 } | 785 } |
| 777 } | 786 } |
| 778 | 787 |
| 779 } // namespace memory | 788 } // namespace memory |
| OLD | NEW |