Skip to content

Commit

Permalink
[M109] Binding Manager Connection Limit: Additional Metrics
Browse files Browse the repository at this point in the history
Additional metric recording:
* Waived binding OOM count.
* Number of times bindings are dropped from hitting the BindingManager
  max connection limit.

These metrics should help inform whether the BindingManagerConnection
limit experiment makes sense to launch.

(cherry picked from commit 1b56458)

Bug: 1385812
Change-Id: I55a278f5f6a43ca08756674b8f4677efec0902ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4031089
Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Bo Liu <boliu@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1073004}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4037287
Auto-Submit: Calder Kitagawa <ckitagawa@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
Commit-Queue: Yaron Friedman <yfriedman@chromium.org>
Cr-Commit-Position: refs/branch-heads/5414@{chromium#145}
Cr-Branched-From: 4417ee5-refs/heads/main@{#1070088}
  • Loading branch information
ckitagawa-work authored and Chromium LUCI CQ committed Nov 18, 2022
1 parent b9179fa commit bb41edd
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,14 @@ void CrashMetricsReporter::ChildProcessExited(
// the bindings are updated later than visibility on web contents.
switch (info.binding_state) {
case base::android::ChildBindingState::UNBOUND:
break;
case base::android::ChildBindingState::WAIVED:
if (!intentional_kill && !info.normal_termination) {
ReportCrashCount(
ProcessedCrashCounts::
kRendererForegroundInvisibleWithWaivedBindingOom,
&reported_counts);
}
break;
case base::android::ChildBindingState::STRONG:
if (intentional_kill || info.normal_termination) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class CrashMetricsReporter {
kRendererForegroundInvisibleWithVisibleBindingOom = 21,
kRendererForegroundInvisibleWithNotPerceptibleBindingKilled = 22,
kRendererForegroundInvisibleWithNotPerceptibleBindingOom = 23,
kMaxValue = kRendererForegroundInvisibleWithNotPerceptibleBindingOom
kRendererForegroundInvisibleWithWaivedBindingOom = 24,
kMaxValue = kRendererForegroundInvisibleWithWaivedBindingOom
};
using ReportedCrashTypeSet = base::flat_set<ProcessedCrashCounts>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import androidx.collection.ArraySet;

import org.chromium.base.Log;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.process_launcher.ChildProcessConnection;
import org.chromium.content_public.browser.ContentFeatureList;
import org.chromium.content_public.common.ContentFeatures;
Expand Down Expand Up @@ -48,6 +49,8 @@ class BindingManager implements ComponentCallbacks2 {
// by BindingManager.
private ChildProcessConnection mWaivedConnection;

private int mConnectionsDroppedDueToMaxSize;

@Override
public void onTrimMemory(final int level) {
LauncherThread.post(new Runnable() {
Expand Down Expand Up @@ -142,6 +145,12 @@ private void ensureLowestRankIsWaived() {
*/
void onSentToBackground() {
assert LauncherThread.runningOnLauncherThread();

RecordHistogram.recordCount1000Histogram(
"Android.BindingManger.ConnectionsDroppedDueToMaxSize",
mConnectionsDroppedDueToMaxSize);
mConnectionsDroppedDueToMaxSize = 0;

if (mConnections.isEmpty()) return;
LauncherThread.postDelayed(mDelayedClearer, BINDING_POOL_CLEARER_DELAY_MILLIS);
}
Expand Down Expand Up @@ -243,6 +252,7 @@ public void addConnection(ChildProcessConnection connection) {
addBinding(connection);

if (mMaxSize != NO_MAX_SIZE && mConnections.size() == mMaxSize + 1) {
mConnectionsDroppedDueToMaxSize++;
removeOldConnections(1);
ensureLowestRankIsWaived();
}
Expand Down
2 changes: 2 additions & 0 deletions tools/metrics/histograms/enums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,8 @@ Unknown properties are collapsed to zero. -->
<int value="23"
label="Invisible renderer in foreground app with not perceptible
binding oom"/>
<int value="24"
label="Invisible renderer in foreground app with waived binding oom"/>
</enum>

<enum name="AndroidProcessedMinidumps">
Expand Down
12 changes: 12 additions & 0 deletions tools/metrics/histograms/metadata/android/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,18 @@ chromium-metrics-reviews@google.com.
</summary>
</histogram>

<histogram name="Android.BindingManger.ConnectionsDroppedDueToMaxSize"
units="connections" expires_after="2023-04-16">
<owner>ckitagawa@chromium.org</owner>
<owner>yfriedman@chromium.org</owner>
<summary>
Records the total number of BindingManager bindings to
ChildProcessConnections that were dropped due to the BindingManager reaching
the connection limit. This value accumulates while the app is running and is
emitted upong the app being backgrounded at which time the counter is reset.
</summary>
</histogram>

<histogram name="Android.BiometricAuth.AuthRequester"
enum="BiometricAuthRequester" expires_after="M112">
<owner>ioanap@chromium.org</owner>
Expand Down

0 comments on commit bb41edd

Please sign in to comment.