diff options
author | lizeb <lizeb@chromium.org> | 2016-01-08 09:23:10 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-08 17:24:22 +0000 |
commit | e38b9a18fc67c8107f4aefe97311f593c43e43fa (patch) | |
tree | c64984cab3473ffe7328bc7d15537817471b59a8 /base/android/java | |
parent | 83c66066dafe22d7a723175938459f4440b044c2 (diff) | |
download | chromium_src-e38b9a18fc67c8107f4aefe97311f593c43e43fa.zip chromium_src-e38b9a18fc67c8107f4aefe97311f593c43e43fa.tar.gz chromium_src-e38b9a18fc67c8107f4aefe97311f593c43e43fa.tar.bz2 |
android: Properly record the "native library residency" histogram.
Histograms are silently dropped when recorded before the initialization
of StatisticsRecorder. This means that the cold start histogram is
usually dropped as well (since StatisticsRecorder is initialized in
another thread around the same time).
Fix this by recording the histogram much later.
Also record this histogram for warm starts as well.
BUG=568115
Review URL: https://codereview.chromium.org/1568483002
Cr-Commit-Position: refs/heads/master@{#368358}
Diffstat (limited to 'base/android/java')
-rw-r--r-- | base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java b/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java index b5186942..5a6153a 100644 --- a/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java +++ b/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java @@ -170,16 +170,30 @@ public class LibraryLoader { * detrimental to the startup time. */ public void asyncPrefetchLibrariesToMemory() { - if (!mPrefetchLibraryHasBeenCalled.compareAndSet(false, true)) return; + final boolean coldStart = mPrefetchLibraryHasBeenCalled.compareAndSet(false, true); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { TraceEvent.begin("LibraryLoader.asyncPrefetchLibrariesToMemory"); - boolean success = nativeForkAndPrefetchNativeLibrary(true); - if (!success) { - Log.w(TAG, "Forking a process to prefetch the native library failed."); + int percentage = nativePercentageOfResidentNativeLibraryCode(); + boolean success = false; + if (coldStart) { + success = nativeForkAndPrefetchNativeLibrary(); + if (!success) { + Log.w(TAG, "Forking a process to prefetch the native library failed."); + } + } + // As this runs in a background thread, it can be called before histograms are + // initialized. In this instance, histograms are dropped. + RecordHistogram.initialize(); + if (coldStart) { + RecordHistogram.recordBooleanHistogram("LibraryLoader.PrefetchStatus", success); + } + if (percentage != -1) { + String histogram = "LibraryLoader.PercentageOfResidentCodeBeforePrefetch" + + (coldStart ? "_ColdStartup" : "_WarmStartup"); + RecordHistogram.recordEnumeratedHistogram(histogram, percentage, 101); } - RecordHistogram.recordBooleanHistogram("LibraryLoader.PrefetchStatus", success); TraceEvent.end("LibraryLoader.asyncPrefetchLibrariesToMemory"); return null; } @@ -451,5 +465,9 @@ public class LibraryLoader { // Finds the ranges corresponding to the native library pages, forks a new // process to prefetch these pages and waits for it. The new process then // terminates. This is blocking. - private static native boolean nativeForkAndPrefetchNativeLibrary(boolean isColdStart); + private static native boolean nativeForkAndPrefetchNativeLibrary(); + + // Returns the percentage of the native library code page that are currently reseident in + // memory. + private static native int nativePercentageOfResidentNativeLibraryCode(); } |