diff options
author | Yi Kong <yikong@google.com> | 2020-09-08 17:18:08 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-09-08 17:18:08 +0000 |
commit | 425952c29bd828696275baa98c23463dfc8873b9 (patch) | |
tree | be159eccbe904c67664b3c4e41f20bb5f668ad91 | |
parent | 0eb7c66f6e47f21983b3c5a8a46f95e9ec9a13aa (diff) | |
parent | 4e25de73ab25e746d9b7cc5b4f26900adfb6fa21 (diff) | |
download | extras-425952c29bd828696275baa98c23463dfc8873b9.tar.gz |
Merge "profcollectd: Separate profile processing and reporting into two commands"
-rw-r--r-- | profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl | 1 | ||||
-rw-r--r-- | profcollectd/libprofcollectd/binder_service.cpp | 4 | ||||
-rw-r--r-- | profcollectd/libprofcollectd/binder_service.h | 1 | ||||
-rw-r--r-- | profcollectd/libprofcollectd/include/libprofcollectd.hpp | 1 | ||||
-rw-r--r-- | profcollectd/libprofcollectd/interface.cpp | 4 | ||||
-rw-r--r-- | profcollectd/libprofcollectd/lib.rs | 7 | ||||
-rw-r--r-- | profcollectd/libprofcollectd/scheduler.cpp | 16 | ||||
-rw-r--r-- | profcollectd/libprofcollectd/scheduler.h | 3 | ||||
-rw-r--r-- | profcollectd/profcollectctl.rs | 5 |
9 files changed, 40 insertions, 2 deletions
diff --git a/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl b/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl index b78af04c..908123ab 100644 --- a/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl +++ b/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl @@ -23,5 +23,6 @@ interface IProfCollectd { void TerminateCollection(); void TraceOnce(@utf8InCpp String tag); void ProcessProfile(); + void CreateProfileReport(); @utf8InCpp String GetSupportedProvider(); } diff --git a/profcollectd/libprofcollectd/binder_service.cpp b/profcollectd/libprofcollectd/binder_service.cpp index f43f40ee..0e9534b3 100644 --- a/profcollectd/libprofcollectd/binder_service.cpp +++ b/profcollectd/libprofcollectd/binder_service.cpp @@ -67,6 +67,10 @@ Status ProfcollectdBinder::ProcessProfile() { return HandleIfError([=]() { return Scheduler->ProcessProfile(); }); } +Status ProfcollectdBinder::CreateProfileReport() { + return HandleIfError([=]() { return Scheduler->CreateProfileReport(); }); +} + Status ProfcollectdBinder::GetSupportedProvider(std::string* provider) { return HandleIfError([=]() { return Scheduler->GetSupportedProvider(*provider); }); } diff --git a/profcollectd/libprofcollectd/binder_service.h b/profcollectd/libprofcollectd/binder_service.h index 4434427c..e269b56f 100644 --- a/profcollectd/libprofcollectd/binder_service.h +++ b/profcollectd/libprofcollectd/binder_service.h @@ -37,6 +37,7 @@ class ProfcollectdBinder : public BinderService<ProfcollectdBinder>, binder::Status TerminateCollection() override; binder::Status TraceOnce(const std::string& tag) override; binder::Status ProcessProfile() override; + binder::Status CreateProfileReport() override; binder::Status GetSupportedProvider(std::string* provider) override; protected: diff --git a/profcollectd/libprofcollectd/include/libprofcollectd.hpp b/profcollectd/libprofcollectd/include/libprofcollectd.hpp index 74a1b83b..21f7223f 100644 --- a/profcollectd/libprofcollectd/include/libprofcollectd.hpp +++ b/profcollectd/libprofcollectd/include/libprofcollectd.hpp @@ -25,5 +25,6 @@ extern "C" { void TerminateCollection(); void TraceOnce(); void Process(); + void CreateProfileReport(); void ReadConfig(); } diff --git a/profcollectd/libprofcollectd/interface.cpp b/profcollectd/libprofcollectd/interface.cpp index 4359b592..fbc3e79c 100644 --- a/profcollectd/libprofcollectd/interface.cpp +++ b/profcollectd/libprofcollectd/interface.cpp @@ -78,6 +78,10 @@ void Process() { GetIProfcollectdService()->ProcessProfile(); } +void CreateProfileReport() { + GetIProfcollectdService()->CreateProfileReport(); +} + void ReadConfig() { GetIProfcollectdService()->ReadConfig(); } diff --git a/profcollectd/libprofcollectd/lib.rs b/profcollectd/libprofcollectd/lib.rs index 90bca990..80906163 100644 --- a/profcollectd/libprofcollectd/lib.rs +++ b/profcollectd/libprofcollectd/lib.rs @@ -54,6 +54,13 @@ pub fn process() { } } +/// Create profile report. +pub fn create_profile_report() { + unsafe { + profcollectd_bindgen::CreateProfileReport(); + } +} + /// Read configs from environment variables. pub fn read_config() { unsafe { diff --git a/profcollectd/libprofcollectd/scheduler.cpp b/profcollectd/libprofcollectd/scheduler.cpp index 96b0c82d..0c88884f 100644 --- a/profcollectd/libprofcollectd/scheduler.cpp +++ b/profcollectd/libprofcollectd/scheduler.cpp @@ -176,7 +176,21 @@ OptError ProfcollectdScheduler::ProcessProfile() { } const std::lock_guard<std::mutex> lock(mu); - hwtracer->Process(config.traceOutputDir, config.profileOutputDir, config.binaryFilter); + bool success = + hwtracer->Process(config.traceOutputDir, config.profileOutputDir, config.binaryFilter); + if (!success) { + static std::string errmsg = "Process profiles failed"; + return errmsg; + } + return std::nullopt; +} + +OptError ProfcollectdScheduler::CreateProfileReport() { + auto processFailureMsg = ProcessProfile(); + if (processFailureMsg) { + return processFailureMsg; + } + std::vector<fs::path> profiles; profiles.insert(profiles.begin(), fs::directory_iterator(config.profileOutputDir), fs::directory_iterator()); diff --git a/profcollectd/libprofcollectd/scheduler.h b/profcollectd/libprofcollectd/scheduler.h index 492b4182..b1ec07e2 100644 --- a/profcollectd/libprofcollectd/scheduler.h +++ b/profcollectd/libprofcollectd/scheduler.h @@ -52,6 +52,7 @@ class ProfcollectdScheduler { OptError TerminateCollection(); OptError TraceOnce(const std::string& tag); OptError ProcessProfile(); + OptError CreateProfileReport(); OptError GetSupportedProvider(std::string& provider); private: @@ -63,4 +64,4 @@ class ProfcollectdScheduler { }; } // namespace profcollectd -} // namespace android
\ No newline at end of file +} // namespace android diff --git a/profcollectd/profcollectctl.rs b/profcollectd/profcollectctl.rs index 298cca5b..33c94ef1 100644 --- a/profcollectd/profcollectctl.rs +++ b/profcollectd/profcollectctl.rs @@ -30,6 +30,7 @@ command: stop Terminate periodic collection. once Request an one-off trace. process Convert traces to perf profiles. + report Create a report containing all profiles. reconfig Refresh configuration. help Print this message. )"# @@ -61,6 +62,10 @@ fn main() { println!("Processing traces"); libprofcollectd::process(); } + "report" => { + println!("Creating profile report"); + libprofcollectd::create_profile_report(); + } "reconfig" => { println!("Refreshing configuration"); libprofcollectd::read_config(); |