Avoid unnecessary smaps logic during app compaction
ForEachVma can extract data from both maps and smaps files, however the smaps logic is not used during app compaction. Replace its usage with ForEachVmaFromMaps which reads only maps file and skips any smaps logic. This results in ~22% CPU usage reduction. Test: Manual Bug: 181174877 Signed-off-by: Edgar Arriaga <edgararriaga@google.com> Change-Id: I165f211c2084676bc7872d190ffad14141f56ea8
This commit is contained in:
@@ -135,7 +135,7 @@ static int getAnyPageAdvice(const Vma& vma) {
|
||||
static int compactProcess(int pid, VmaToAdviseFunc vmaToAdviseFunc) {
|
||||
ProcMemInfo meminfo(pid);
|
||||
std::vector<Vma> pageoutVmas, coldVmas;
|
||||
auto vmaCollectorCb = [&](Vma vma) {
|
||||
auto vmaCollectorCb = [&coldVmas,&pageoutVmas,&vmaToAdviseFunc](const Vma& vma) {
|
||||
int advice = vmaToAdviseFunc(vma);
|
||||
switch (advice) {
|
||||
case MADV_COLD:
|
||||
@@ -146,7 +146,7 @@ static int compactProcess(int pid, VmaToAdviseFunc vmaToAdviseFunc) {
|
||||
break;
|
||||
}
|
||||
};
|
||||
meminfo.ForEachVma(vmaCollectorCb);
|
||||
meminfo.ForEachVmaFromMaps(vmaCollectorCb);
|
||||
|
||||
int err = compactMemory(pageoutVmas, pid, MADV_PAGEOUT);
|
||||
if (!err) {
|
||||
|
||||
Reference in New Issue
Block a user