summaryrefslogtreecommitdiff
path: root/profcollectd
diff options
context:
space:
mode:
authorYi Kong <yikong@google.com>2021-11-15 16:20:02 +0800
committerYi Kong <yikong@google.com>2021-11-15 14:06:30 +0000
commite762742e32aeb49eb11c71c5138230907b868336 (patch)
treeda92f021ce339a30bede62f0c7d16e430a341609 /profcollectd
parent1eea2bc586fbc8636abb23e37c36a5e5e6814117 (diff)
downloadextras-e762742e32aeb49eb11c71c5138230907b868336.tar.gz
profcollectd: Move threading to framework side
Previously trace processing's threading is handled on the native side while the report creation's threading is on the framework side. Move them all to the frameworks side to reduce complexity. Test: build Bug: 183487233 Change-Id: I48e6b40676b5dd90954b53a463d8ae36ad031210
Diffstat (limited to 'profcollectd')
-rw-r--r--profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl2
-rw-r--r--profcollectd/libprofcollectd/lib.rs2
-rw-r--r--profcollectd/libprofcollectd/scheduler.rs7
-rw-r--r--profcollectd/libprofcollectd/service.rs6
4 files changed, 8 insertions, 9 deletions
diff --git a/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl b/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl
index 58503abc..5dcf1119 100644
--- a/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl
+++ b/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl
@@ -21,7 +21,7 @@ interface IProfCollectd {
void schedule();
void terminate();
void trace_once(@utf8InCpp String tag);
- void process(boolean blocking);
+ void process();
@utf8InCpp String report();
void copy_report_to_bb(int bb_profile_id, @utf8InCpp String report);
void delete_report(@utf8InCpp String report);
diff --git a/profcollectd/libprofcollectd/lib.rs b/profcollectd/libprofcollectd/lib.rs
index d5eec68c..d8a8cc8d 100644
--- a/profcollectd/libprofcollectd/lib.rs
+++ b/profcollectd/libprofcollectd/lib.rs
@@ -82,7 +82,7 @@ pub fn trace_once(tag: &str) -> Result<()> {
/// Process traces.
pub fn process() -> Result<()> {
- get_profcollectd_service()?.process(true)?;
+ get_profcollectd_service()?.process()?;
Ok(())
}
diff --git a/profcollectd/libprofcollectd/scheduler.rs b/profcollectd/libprofcollectd/scheduler.rs
index cfd0381f..883a616d 100644
--- a/profcollectd/libprofcollectd/scheduler.rs
+++ b/profcollectd/libprofcollectd/scheduler.rs
@@ -87,7 +87,7 @@ impl Scheduler {
Ok(())
}
- pub fn process(&self, blocking: bool) -> Result<()> {
+ pub fn process(&self) -> Result<()> {
let trace_provider = self.trace_provider.clone();
let handle = thread::spawn(move || {
trace_provider
@@ -96,9 +96,8 @@ impl Scheduler {
.process(&TRACE_OUTPUT_DIR, &PROFILE_OUTPUT_DIR)
.expect("Failed to process profiles.");
});
- if blocking {
- handle.join().map_err(|_| anyhow!("Profile process thread panicked."))?;
- }
+
+ handle.join().map_err(|_| anyhow!("Profile process thread panicked."))?;
Ok(())
}
diff --git a/profcollectd/libprofcollectd/service.rs b/profcollectd/libprofcollectd/service.rs
index 021271f3..8f998947 100644
--- a/profcollectd/libprofcollectd/service.rs
+++ b/profcollectd/libprofcollectd/service.rs
@@ -73,15 +73,15 @@ impl IProfCollectd for ProfcollectdBinderService {
.context("Failed to initiate an one-off trace.")
.map_err(err_to_binder_status)
}
- fn process(&self, blocking: bool) -> BinderResult<()> {
+ fn process(&self) -> BinderResult<()> {
let lock = &mut *self.lock();
lock.scheduler
- .process(blocking)
+ .process()
.context("Failed to process profiles.")
.map_err(err_to_binder_status)
}
fn report(&self) -> BinderResult<String> {
- self.process(true)?;
+ self.process()?;
let lock = &mut *self.lock();
pack_report(&PROFILE_OUTPUT_DIR, &REPORT_OUTPUT_DIR, &lock.config)