summaryrefslogtreecommitdiff
path: root/profcollectd
diff options
context:
space:
mode:
authorYi Kong <yikong@google.com>2021-11-17 00:09:02 +0800
committerYi Kong <yikong@google.com>2021-11-17 00:50:24 +0800
commit49eb6ff442c595d1f4887a571382f222e29a87c8 (patch)
tree30f98bdba263b29b30ae79e967e435c78dc59252 /profcollectd
parent8565b665fae91572b3090c34e5957615ee8e9e02 (diff)
downloadextras-49eb6ff442c595d1f4887a571382f222e29a87c8.tar.gz
profcollectd: only produce profiles for /system/{bin,lib,lib64}/*
For now, all the PGO enabled libraries are in these directories. Filtering the profiles saves us some processing time. We can add more paths if needed in the future. Test: manual Bug: 79161490 Change-Id: Ibb992f63990deacd8dbfa8c88e6e6098b9e22ccf
Diffstat (limited to 'profcollectd')
-rw-r--r--profcollectd/libprofcollectd/scheduler.rs4
-rw-r--r--profcollectd/libprofcollectd/simpleperf_etm_trace_provider.rs4
-rw-r--r--profcollectd/libprofcollectd/trace_provider.rs2
3 files changed, 6 insertions, 4 deletions
diff --git a/profcollectd/libprofcollectd/scheduler.rs b/profcollectd/libprofcollectd/scheduler.rs
index 883a616d..526345b4 100644
--- a/profcollectd/libprofcollectd/scheduler.rs
+++ b/profcollectd/libprofcollectd/scheduler.rs
@@ -25,6 +25,8 @@ use crate::config::{Config, PROFILE_OUTPUT_DIR, TRACE_OUTPUT_DIR};
use crate::trace_provider::{self, TraceProvider};
use anyhow::{anyhow, ensure, Context, Result};
+static BINARY_FILTER: &str = "^(/system/bin/|/system/lib/|/system/lib64/).+";
+
pub struct Scheduler {
/// Signal to terminate the periodic collection worker thread, None if periodic collection is
/// not scheduled.
@@ -93,7 +95,7 @@ impl Scheduler {
trace_provider
.lock()
.unwrap()
- .process(&TRACE_OUTPUT_DIR, &PROFILE_OUTPUT_DIR)
+ .process(&TRACE_OUTPUT_DIR, &PROFILE_OUTPUT_DIR, BINARY_FILTER)
.expect("Failed to process profiles.");
});
diff --git a/profcollectd/libprofcollectd/simpleperf_etm_trace_provider.rs b/profcollectd/libprofcollectd/simpleperf_etm_trace_provider.rs
index d3baaa36..b993007b 100644
--- a/profcollectd/libprofcollectd/simpleperf_etm_trace_provider.rs
+++ b/profcollectd/libprofcollectd/simpleperf_etm_trace_provider.rs
@@ -44,7 +44,7 @@ impl TraceProvider for SimpleperfEtmTraceProvider {
);
}
- fn process(&self, trace_dir: &Path, profile_dir: &Path) -> Result<()> {
+ fn process(&self, trace_dir: &Path, profile_dir: &Path, binary_filter: &str) -> Result<()> {
read_dir(trace_dir)?
.filter_map(|e| e.ok())
.map(|e| e.path())
@@ -63,7 +63,7 @@ impl TraceProvider for SimpleperfEtmTraceProvider {
.ok_or_else(|| anyhow!("Malformed trace path: {}", trace_file.display()))?,
);
profile_file.set_extension(ETM_PROFILE_EXTENSION);
- simpleperf_profcollect::process(&trace_file, &profile_file);
+ simpleperf_profcollect::process(&trace_file, &profile_file, binary_filter);
remove_file(&trace_file)?;
Ok(())
})
diff --git a/profcollectd/libprofcollectd/trace_provider.rs b/profcollectd/libprofcollectd/trace_provider.rs
index 44d4cee9..98cd5ec4 100644
--- a/profcollectd/libprofcollectd/trace_provider.rs
+++ b/profcollectd/libprofcollectd/trace_provider.rs
@@ -30,7 +30,7 @@ use crate::logging_trace_provider::LoggingTraceProvider;
pub trait TraceProvider {
fn get_name(&self) -> &'static str;
fn trace(&self, trace_dir: &Path, tag: &str, sampling_period: &Duration);
- fn process(&self, trace_dir: &Path, profile_dir: &Path) -> Result<()>;
+ fn process(&self, trace_dir: &Path, profile_dir: &Path, binary_filter: &str) -> Result<()>;
}
pub fn get_trace_provider() -> Result<Arc<Mutex<dyn TraceProvider + Send>>> {