diff options
author | asharif@chromium.org <asharif@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-04 20:00:25 +0000 |
---|---|---|
committer | asharif@chromium.org <asharif@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-04 20:00:25 +0000 |
commit | f65859e8e1414ffba1b165be9d89745d42ffec79 (patch) | |
tree | fe046f738bcf77820b0e5047ecef8b7a9304ca2a /chromeos | |
parent | 5bb22d0294fb13c712f8185c1e6d8e66655d7443 (diff) | |
download | chromium_src-f65859e8e1414ffba1b165be9d89745d42ffec79.zip chromium_src-f65859e8e1414ffba1b165be9d89745d42ffec79.tar.gz chromium_src-f65859e8e1414ffba1b165be9d89745d42ffec79.tar.bz2 |
Chrome: Enable ChromeOS-Wide-Profiling
We want to gather perf data collected by running "perf record -a" from opt-in
ChromeOS users. This CL enables that.
We use debugd in ChromeOS to run quipper, a program that runs "perf record -a"
and returns that data in a protobuf. We do this every 12 hours for 2 seconds.
The overhead is minimal (5% slowdown for 2 seconds on "lumpy" machines).
BUG=157508
TEST=Manual:
Change the perf record interval from 12 hours to 1 minute and set a
breakpoint on ParseProtoIfValid(). It gets hit and the protobuf is parsed
properly.
Review URL: https://chromiumcodereview.appspot.com/11185038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180484 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/dbus/debug_daemon_client.cc | 42 | ||||
-rw-r--r-- | chromeos/dbus/debug_daemon_client.h | 13 | ||||
-rw-r--r-- | chromeos/dbus/mock_debug_daemon_client.h | 1 |
3 files changed, 56 insertions, 0 deletions
diff --git a/chromeos/dbus/debug_daemon_client.cc b/chromeos/dbus/debug_daemon_client.cc index c9212d3..cd3b24a 100644 --- a/chromeos/dbus/debug_daemon_client.cc +++ b/chromeos/dbus/debug_daemon_client.cc @@ -245,6 +245,21 @@ class DebugDaemonClientImpl : public DebugDaemonClient { callback)); } + virtual void GetPerfData(uint32_t duration, + const GetPerfDataCallback& callback) OVERRIDE { + dbus::MethodCall method_call(debugd::kDebugdInterface, + debugd::kGetPerfData); + dbus::MessageWriter writer(&method_call); + writer.AppendUint32(duration); + + debugdaemon_proxy_->CallMethod( + &method_call, + dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, + base::Bind(&DebugDaemonClientImpl::OnGetPerfData, + weak_ptr_factory_.GetWeakPtr(), + callback)); + } + virtual void GetAllLogs(const GetLogsCallback& callback) OVERRIDE { dbus::MethodCall method_call(debugd::kDebugdInterface, @@ -423,6 +438,28 @@ class DebugDaemonClientImpl : public DebugDaemonClient { callback.Run(false, ""); } + void OnGetPerfData(const GetPerfDataCallback& callback, + dbus::Response* response) { + std::vector<uint8> data; + + if (!response) { + return; + } + + dbus::MessageReader reader(response); + uint8* buffer = NULL; + size_t buf_size = 0; + if (!reader.PopArrayOfBytes(reinterpret_cast<uint8**>( + &buffer), &buf_size)) { + return; + } + + // TODO(asharif): Figure out a way to avoid this copy. + data.insert(data.end(), buffer, buffer + buf_size); + + callback.Run(data); + } + void OnGetAllLogs(const GetLogsCallback& callback, dbus::Response* response) { std::map<std::string, std::string> logs; @@ -556,6 +593,11 @@ class DebugDaemonClientStubImpl : public DebugDaemonClient { MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, false, "")); } + virtual void GetPerfData(uint32_t duration, + const GetPerfDataCallback& callback) OVERRIDE { + std::vector<uint8> data; + MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, data)); + } virtual void GetAllLogs(const GetLogsCallback& callback) OVERRIDE { std::map<std::string, std::string> empty; MessageLoop::current()->PostTask(FROM_HERE, diff --git a/chromeos/dbus/debug_daemon_client.h b/chromeos/dbus/debug_daemon_client.h index 073189c..1ed0215 100644 --- a/chromeos/dbus/debug_daemon_client.h +++ b/chromeos/dbus/debug_daemon_client.h @@ -17,6 +17,10 @@ namespace dbus { class Bus; } // namespace dbus +namespace metrics { +class PerfDataProto; +} + namespace chromeos { // DebugDaemonClient is used to communicate with the debug daemon. @@ -75,6 +79,15 @@ class CHROMEOS_EXPORT DebugDaemonClient { virtual void GetNetworkInterfaces( const GetNetworkInterfacesCallback& callback) = 0; + // Called once GetPerfData() is complete only if the the data is successfully + // obtained from debugd. + typedef base::Callback<void(const std::vector<uint8>& data)> + GetPerfDataCallback; + + // Runs perf for |duration| seconds and returns data collected. + virtual void GetPerfData(uint32_t duration, + const GetPerfDataCallback& callback) = 0; + // Callback type for GetAllLogs() or GetUserLogFiles(). typedef base::Callback<void(bool succeeded, const std::map<std::string, std::string>& logs)> diff --git a/chromeos/dbus/mock_debug_daemon_client.h b/chromeos/dbus/mock_debug_daemon_client.h index 56cd2c4..5f4813f 100644 --- a/chromeos/dbus/mock_debug_daemon_client.h +++ b/chromeos/dbus/mock_debug_daemon_client.h @@ -23,6 +23,7 @@ class MockDebugDaemonClient : public DebugDaemonClient { MOCK_METHOD1(GetNetworkStatus, void(const GetNetworkStatusCallback&)); MOCK_METHOD1(GetModemStatus, void(const GetModemStatusCallback&)); MOCK_METHOD1(GetNetworkInterfaces, void(const GetNetworkInterfacesCallback&)); + MOCK_METHOD2(GetPerfData, void(uint32_t, const GetPerfDataCallback&)); MOCK_METHOD1(GetAllLogs, void(const GetLogsCallback&)); MOCK_METHOD1(GetUserLogFiles, void(const GetLogsCallback&)); MOCK_METHOD1(RequestStopSystemTracing, |