Skip to content

Commit

Permalink
tp: scope args tracker for surfaceflinger parsing to packet
Browse files Browse the repository at this point in the history
This CL scopes the ArgsTracker to only the lifetime of parsing the
surfaceflinger packets. This significantly reduces the memory use when
parsing traces containing these packets.

Change-Id: I08a79619e28f42b5d54cc3756611cd6fb999b574
  • Loading branch information
LalitMaganti committed Sep 25, 2023
1 parent 43ee4b9 commit 0544187
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ void SurfaceFlingerLayersParser::ParseLayer(
auto layerId =
context_->storage->mutable_surfaceflinger_layer_table()->Insert(layer).id;

auto inserter = context_->args_tracker->AddArgsTo(layerId);
ArgsTracker tracker(context_);
auto inserter = tracker.AddArgsTo(layerId);
WinscopeArgsParser writer(inserter, *context_->storage.get());
base::Status status = args_parser_.ParseMessage(
blob, kLayerProtoName, nullptr /* parse all fields */, writer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ void SurfaceFlingerTransactionsParser::Parse(int64_t timestamp,
->Insert(row)
.id;

auto inserter = context_->args_tracker->AddArgsTo(rowId);
ArgsTracker tracker(context_);
auto inserter = tracker.AddArgsTo(rowId);
WinscopeArgsParser writer(inserter, *context_->storage.get());
base::Status status =
args_parser_.ParseMessage(blob, kTransactionTraceEntryProtoName,
Expand Down
1 change: 1 addition & 0 deletions src/trace_processor/trace_processor_storage_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ void TraceProcessorStorageImpl::Flush() {

if (context_.sorter)
context_.sorter->ExtractEventsForced();
context_.args_tracker->Flush();
}

void TraceProcessorStorageImpl::NotifyEndOfFile() {
Expand Down
40 changes: 20 additions & 20 deletions test/trace_processor/diff_tests/chrome/tests_processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_chrome_missing_processes_default_trace(self):
return DiffTestBlueprint(
trace=DataPath('chrome_scroll_without_vsync.pftrace'),
query="""
SELECT upid, pid, reliable_from
SELECT pid, reliable_from
FROM
experimental_missing_chrome_processes
JOIN
Expand All @@ -153,7 +153,7 @@ def test_chrome_missing_processes_default_trace(self):
ORDER BY upid;
""",
out=Csv("""
"upid","pid","reliable_from"
"pid","reliable_from"
"""))

def test_chrome_missing_processes(self):
Expand Down Expand Up @@ -197,7 +197,7 @@ def test_chrome_missing_processes(self):
}
"""),
query="""
SELECT upid, pid, reliable_from
SELECT pid, reliable_from
FROM
experimental_missing_chrome_processes
JOIN
Expand All @@ -206,9 +206,9 @@ def test_chrome_missing_processes(self):
ORDER BY upid;
""",
out=Csv("""
"upid","pid","reliable_from"
2,100,1000000000
3,1000,"[NULL]"
"pid","reliable_from"
100,1000000000
1000,"[NULL]"
"""))

def test_chrome_missing_processes_args(self):
Expand Down Expand Up @@ -252,7 +252,7 @@ def test_chrome_missing_processes_args(self):
}
"""),
query="""
SELECT arg_set_id, key, int_value
SELECT slice.name, key, int_value
FROM
slice
JOIN
Expand All @@ -261,10 +261,10 @@ def test_chrome_missing_processes_args(self):
ORDER BY arg_set_id, key;
""",
out=Csv("""
"arg_set_id","key","int_value"
2,"chrome_active_processes.pid[0]",10
2,"chrome_active_processes.pid[1]",100
2,"chrome_active_processes.pid[2]",1000
"name","key","int_value"
"ActiveProcesses","chrome_active_processes.pid[0]",10
"ActiveProcesses","chrome_active_processes.pid[1]",100
"ActiveProcesses","chrome_active_processes.pid[2]",1000
"""))

def test_chrome_missing_processes_2(self):
Expand Down Expand Up @@ -308,7 +308,7 @@ def test_chrome_missing_processes_2(self):
}
"""),
query="""
SELECT upid, pid, reliable_from
SELECT pid, reliable_from
FROM
experimental_missing_chrome_processes
JOIN
Expand All @@ -317,9 +317,9 @@ def test_chrome_missing_processes_2(self):
ORDER BY upid;
""",
out=Csv("""
"upid","pid","reliable_from"
2,100,1000000000
3,1000,"[NULL]"
"pid","reliable_from"
100,1000000000
1000,"[NULL]"
"""))

def test_chrome_missing_processes_extension_args(self):
Expand Down Expand Up @@ -363,7 +363,7 @@ def test_chrome_missing_processes_extension_args(self):
}
"""),
query="""
SELECT arg_set_id, key, int_value
SELECT slice.name, key, int_value
FROM
slice
JOIN
Expand All @@ -372,8 +372,8 @@ def test_chrome_missing_processes_extension_args(self):
ORDER BY arg_set_id, key;
""",
out=Csv("""
"arg_set_id","key","int_value"
2,"active_processes.pid[0]",10
2,"active_processes.pid[1]",100
2,"active_processes.pid[2]",1000
"name","key","int_value"
"ActiveProcesses","active_processes.pid[0]",10
"ActiveProcesses","active_processes.pid[1]",100
"ActiveProcesses","active_processes.pid[2]",1000
"""))

0 comments on commit 0544187

Please sign in to comment.