diff options
| author | Shukang Zhou <shukang@google.com> | 2017-01-24 15:30:29 -0800 |
|---|---|---|
| committer | Shukang Zhou <shukang@google.com> | 2017-01-30 13:07:40 -0800 |
| commit | bb44e42de93e2e02d4314ffdee4cbc4d0df7ecc2 (patch) | |
| tree | 3a93b2b04edf99efd88bb7527cd2b2aa60d42792 /core/java/android | |
| parent | 95451d53907ca8befe2ae362947643cf983a0497 (diff) | |
[Frameworks] Add an 'am' cmd option to enable streaming in profiling.
Add option '--streaming' to 'am start' and 'am profile' commands.
If the option is given, the output of method trace profiling
will be streamed into the specified file, so the output is no
longer limited by the buffer size.
Test: m -j48 test-art-host;
m -j48 ART_TEST_TRACE=true ART_TEST_TRACE_STREAM=true test-art-host;
I also tested manually. Tried all 8 combinations of
sampling/instrumention
streaming/non-streaming
'am start --start-profiler' / 'am profile start'
The output files are all in expected shape.
Bug: 33300765
Merged-In: I8a5136a1c7330c8260b7c6c8da63f42a73aee275
Change-Id: I8a5136a1c7330c8260b7c6c8da63f42a73aee275
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 6 | ||||
| -rw-r--r-- | core/java/android/app/ProfilerInfo.java | 9 | ||||
| -rw-r--r-- | core/java/android/os/Debug.java | 4 |
3 files changed, 15 insertions, 4 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 9d2ef9147388..18b7e24a0172 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -535,6 +535,7 @@ public final class ActivityThread { ParcelFileDescriptor profileFd; int samplingInterval; boolean autoStopProfiler; + boolean streamingOutput; boolean profiling; boolean handlingProfiling; public void setProfiler(ProfilerInfo profilerInfo) { @@ -560,6 +561,7 @@ public final class ActivityThread { profileFd = fd; samplingInterval = profilerInfo.samplingInterval; autoStopProfiler = profilerInfo.autoStopProfiler; + streamingOutput = profilerInfo.streamingOutput; } public void startProfiling() { if (profileFd == null || profiling) { @@ -568,7 +570,8 @@ public final class ActivityThread { try { int bufferSize = SystemProperties.getInt("debug.traceview-buffer-size-mb", 8); VMDebug.startMethodTracing(profileFile, profileFd.getFileDescriptor(), - bufferSize * 1024 * 1024, 0, samplingInterval != 0, samplingInterval); + bufferSize * 1024 * 1024, 0, samplingInterval != 0, samplingInterval, + streamingOutput); profiling = true; } catch (RuntimeException e) { Slog.w(TAG, "Profiling failed on path " + profileFile); @@ -5111,6 +5114,7 @@ public final class ActivityThread { mProfiler.profileFd = data.initProfilerInfo.profileFd; mProfiler.samplingInterval = data.initProfilerInfo.samplingInterval; mProfiler.autoStopProfiler = data.initProfilerInfo.autoStopProfiler; + mProfiler.streamingOutput = data.initProfilerInfo.streamingOutput; } // send up app name; do this *before* waiting for debugger diff --git a/core/java/android/app/ProfilerInfo.java b/core/java/android/app/ProfilerInfo.java index cea7c3cbe8c3..f3fe6778375b 100644 --- a/core/java/android/app/ProfilerInfo.java +++ b/core/java/android/app/ProfilerInfo.java @@ -39,11 +39,16 @@ public class ProfilerInfo implements Parcelable { /* Automatically stop the profiler when the app goes idle. */ public final boolean autoStopProfiler; - public ProfilerInfo(String filename, ParcelFileDescriptor fd, int interval, boolean autoStop) { + /* Indicates whether to stream the profiling info to the out file continuously. */ + public final boolean streamingOutput; + + public ProfilerInfo(String filename, ParcelFileDescriptor fd, int interval, boolean autoStop, + boolean streaming) { profileFile = filename; profileFd = fd; samplingInterval = interval; autoStopProfiler = autoStop; + streamingOutput = streaming; } public int describeContents() { @@ -64,6 +69,7 @@ public class ProfilerInfo implements Parcelable { } out.writeInt(samplingInterval); out.writeInt(autoStopProfiler ? 1 : 0); + out.writeInt(streamingOutput ? 1 : 0); } public static final Parcelable.Creator<ProfilerInfo> CREATOR = @@ -82,5 +88,6 @@ public class ProfilerInfo implements Parcelable { profileFd = in.readInt() != 0 ? ParcelFileDescriptor.CREATOR.createFromParcel(in) : null; samplingInterval = in.readInt(); autoStopProfiler = in.readInt() != 0; + streamingOutput = in.readInt() != 0; } } diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java index 175d883da29d..210ddb6cd397 100644 --- a/core/java/android/os/Debug.java +++ b/core/java/android/os/Debug.java @@ -1119,8 +1119,8 @@ public final class Debug * @hide */ public static void startMethodTracing(String traceName, FileDescriptor fd, - int bufferSize, int flags) { - VMDebug.startMethodTracing(traceName, fd, bufferSize, flags, false, 0); + int bufferSize, int flags, boolean streamOutput) { + VMDebug.startMethodTracing(traceName, fd, bufferSize, flags, false, 0, streamOutput); } /** |
