Skip to content

Commit

Permalink
[aw][power] Remove AwDebug power scheduler methods
Browse files Browse the repository at this point in the history
This change removes the Power Scheduler-related methods from AwDebug
and marks the Android.WebView.AwDebugCall histogram as obsolete.

Bug: 1166695, 1281444, b/193902731
Change-Id: I561ec4b3b574dc3d709729d60e6bec980b788693
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3370723
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Nate Fischer <ntfschr@chromium.org>
Reviewed-by: Brian White <bcwhite@chromium.org>
Commit-Queue: Oksana Zhuravlova <oksamyt@chromium.org>
Cr-Commit-Position: refs/heads/main@{#957764}
  • Loading branch information
Oksana Zhuravlova authored and Chromium LUCI CQ committed Jan 11, 2022
1 parent b5b1033 commit b71a3c6
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 144 deletions.
67 changes: 0 additions & 67 deletions android_webview/browser/aw_debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,78 +9,11 @@
#include "base/android/jni_string.h"
#include "base/no_destructor.h"
#include "components/crash/core/common/crash_key.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_process_host_creation_observer.h"

using content::RenderProcessHost;

namespace android_webview {

class AwDebugCpuAffinity : public content::RenderProcessHostCreationObserver {
public:
AwDebugCpuAffinity(bool enable_idle_throttling,
int32_t policy,
int32_t min_time_ms,
float min_cputime_ratio)
: enable_idle_throttling_(enable_idle_throttling),
policy_(policy),
min_time_ms_(min_time_ms),
min_cputime_ratio_(min_cputime_ratio) {
for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
!i.IsAtEnd(); i.Advance()) {
RenderProcessHost* process_host = i.GetCurrentValue();
if (process_host) {
if (enable_idle_throttling_)
EnableIdleThrottling(process_host);
else
SetAffinityForProcessHost(process_host);
}
}
}

// content::RenderProcessHostCreationObserver:
void OnRenderProcessHostCreated(RenderProcessHost* process_host) override {
if (enable_idle_throttling_)
EnableIdleThrottling(process_host);
else
SetAffinityForProcessHost(process_host);
}

private:
void SetAffinityForProcessHost(RenderProcessHost* process_host) {
process_host->PostTaskWhenProcessIsReady(base::BindOnce(
&AwRenderProcess::SetCpuAffinityToLittleCores,
base::Unretained(
AwRenderProcess::GetInstanceForRenderProcessHost(process_host))));
}

void EnableIdleThrottling(RenderProcessHost* process_host) {
process_host->PostTaskWhenProcessIsReady(base::BindOnce(
&AwRenderProcess::EnableIdleThrottling,
base::Unretained(
AwRenderProcess::GetInstanceForRenderProcessHost(process_host)),
policy_, min_time_ms_, min_cputime_ratio_));
}

bool enable_idle_throttling_{false};
int32_t policy_;
int32_t min_time_ms_;
float min_cputime_ratio_;
};

static void JNI_AwDebug_SetCpuAffinityToLittleCores(JNIEnv* env) {
static base::NoDestructor<AwDebugCpuAffinity> aw_debug_cpu_affinity(false, 1,
0, 0);
}

static void JNI_AwDebug_EnableIdleThrottling(JNIEnv* env,
int policy,
int min_time_ms,
float min_cputime_ratio) {
static base::NoDestructor<AwDebugCpuAffinity> aw_debug_cpu_affinity(
true, policy, min_time_ms, min_cputime_ratio);
}

static void JNI_AwDebug_SetSupportLibraryWebkitVersionCrashKey(
JNIEnv* env,
const base::android::JavaParamRef<jstring>& version) {
Expand Down
11 changes: 0 additions & 11 deletions android_webview/browser/aw_render_process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,6 @@ void AwRenderProcess::SetJsOnlineProperty(bool network_up) {
renderer_remote_->SetJsOnlineProperty(network_up);
}

void AwRenderProcess::SetCpuAffinityToLittleCores() {
renderer_remote_->SetCpuAffinityToLittleCores();
}

void AwRenderProcess::EnableIdleThrottling(int32_t policy,
int32_t min_time_ms,
float min_cputime_ratio) {
renderer_remote_->EnableIdleThrottling(policy, min_time_ms,
min_cputime_ratio);
}

void AwRenderProcess::Ready() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);

Expand Down
4 changes: 0 additions & 4 deletions android_webview/browser/aw_render_process.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ class AwRenderProcess : public content::RenderProcessHostObserver,

void ClearCache();
void SetJsOnlineProperty(bool network_up);
void SetCpuAffinityToLittleCores();
void EnableIdleThrottling(int32_t policy,
int32_t min_time_ms,
float min_cputime_ratio);

private:
void Ready();
Expand Down
8 changes: 0 additions & 8 deletions android_webview/common/mojom/renderer.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,4 @@ interface Renderer {

// Adjusts the javascript 'online' property value.
SetJsOnlineProperty(bool network_up);

// Set renderer process CPU affinity to little cores. Temporarily added for an
// experiment; to be deleted after its conclusion (https://crbug.com/1111789).
SetCpuAffinityToLittleCores();

// Enable idle throttling in the renderer. Temporarily added for an
// experiment; to be deleted after its conclusion (https://crbug.com/1166695).
EnableIdleThrottling(int32 policy, int32 min_time_ms, float min_cputime_ratio);
};
36 changes: 0 additions & 36 deletions android_webview/java/src/org/chromium/android_webview/AwDebug.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@

package org.chromium.android_webview;

import androidx.annotation.IntDef;

import org.chromium.base.Log;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.annotations.UsedByReflection;
import org.chromium.base.metrics.RecordHistogram;

import java.io.File;

Expand Down Expand Up @@ -41,41 +38,8 @@ public static void setSupportLibraryWebkitVersionCrashKey(String version) {
AwDebugJni.get().setSupportLibraryWebkitVersionCrashKey(version);
}

// Used to record the UMA histogram Android.WebView.AwDebugCall. Since these values are
// persisted to logs, they should never be renumbered or reused.
@IntDef({AwDebugCall.SET_CPU_AFFINITY_TO_LITTLE_CORES, AwDebugCall.ENABLE_IDLE_THROTTLING})
@interface AwDebugCall {
int SET_CPU_AFFINITY_TO_LITTLE_CORES = 0;
int ENABLE_IDLE_THROTTLING = 1;
int ENABLE_POWER_SCHEDULER = 2;
int COUNT = 3;
}

@UsedByReflection("")
public static void setCpuAffinityToLittleCores() {
RecordHistogram.recordEnumeratedHistogram("Android.WebView.AwDebugCall",
AwDebugCall.SET_CPU_AFFINITY_TO_LITTLE_CORES, AwDebugCall.COUNT);
AwDebugJni.get().setCpuAffinityToLittleCores();
}

@UsedByReflection("")
public static void enableIdleThrottling() {
RecordHistogram.recordEnumeratedHistogram("Android.WebView.AwDebugCall",
AwDebugCall.ENABLE_IDLE_THROTTLING, AwDebugCall.COUNT);
AwDebugJni.get().enableIdleThrottling(3, 500, 0.5f);
}

@UsedByReflection("")
public static void enablePowerScheduler(int policy, int minTimeMs, float minCputimeRatio) {
RecordHistogram.recordEnumeratedHistogram("Android.WebView.AwDebugCall",
AwDebugCall.ENABLE_POWER_SCHEDULER, AwDebugCall.COUNT);
AwDebugJni.get().enableIdleThrottling(policy, minTimeMs, minCputimeRatio);
}

@NativeMethods
interface Natives {
void setSupportLibraryWebkitVersionCrashKey(String version);
void setCpuAffinityToLittleCores();
void enableIdleThrottling(int policy, int minTimeMs, float minCputimeRatio);
}
}
14 changes: 0 additions & 14 deletions android_webview/renderer/aw_render_thread_observer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,4 @@ void AwRenderThreadObserver::SetJsOnlineProperty(bool network_up) {
blink::WebNetworkStateNotifier::SetOnLine(network_up);
}

void AwRenderThreadObserver::SetCpuAffinityToLittleCores() {
power_scheduler::PowerScheduler::GetInstance()->SetPolicy(
power_scheduler::SchedulingPolicy::kLittleCoresOnly);
}

void AwRenderThreadObserver::EnableIdleThrottling(int32_t policy,
int32_t min_time_ms,
float min_cputime_ratio) {
power_scheduler::SchedulingPolicyParams params{
(power_scheduler::SchedulingPolicy)policy,
base::Milliseconds(min_time_ms), min_cputime_ratio};
power_scheduler::PowerScheduler::GetInstance()->SetPolicy(params);
}

} // namespace android_webview
4 changes: 0 additions & 4 deletions android_webview/renderer/aw_render_thread_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ class AwRenderThreadObserver : public content::RenderThreadObserver,
// mojom::Renderer overrides:
void ClearCache() override;
void SetJsOnlineProperty(bool network_up) override;
void SetCpuAffinityToLittleCores() override;
void EnableIdleThrottling(int32_t policy,
int32_t min_time_ms,
float min_cputime_ratio) override;

void OnRendererAssociatedRequest(
mojo::PendingAssociatedReceiver<mojom::Renderer> receiver);
Expand Down
3 changes: 3 additions & 0 deletions tools/metrics/histograms/metadata/android/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3556,6 +3556,9 @@ chromium-metrics-reviews@google.com.

<histogram name="Android.WebView.AwDebugCall" enum="AwDebugCall"
expires_after="2022-01-31">
<obsolete>
Removed in January 2022.
</obsolete>
<owner>oksamyt@chromium.org</owner>
<owner>src/android_webview/OWNERS</owner>
<summary>
Expand Down

0 comments on commit b71a3c6

Please sign in to comment.