Commit 9afce604 authored by Egor Pasko's avatar Egor Pasko Committed by Commit Bot

BackgroundTaskScheduler: allow ignoring jobs for benchmarking

Introduce a commandline flag --ignore-background-tasks that would be set
by Telemetry when running startup benchmarks to avoid random tasks from
caching the process and skewing the metrics that are based on process
creation.

The bug has an example trace and more details.

Bug: 890424
Change-Id: I456e0f15406ebba7c930f8ec445da0759e9a087d
Reviewed-on: https://chromium-review.googlesource.com/1252382Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Commit-Queue: Egor Pasko <pasko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595188}
parent 8420c60c
......@@ -7,6 +7,7 @@ package org.chromium.components.background_task_scheduler;
import android.content.Context;
import android.os.Build;
import org.chromium.base.CommandLine;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.TraceEvent;
......@@ -21,6 +22,7 @@ import java.util.Set;
*/
class BackgroundTaskSchedulerImpl implements BackgroundTaskScheduler {
private static final String TAG = "BkgrdTaskScheduler";
private static final String SWITCH_IGNORE_BACKGROUND_TASKS = "ignore-background-tasks";
private final BackgroundTaskSchedulerDelegate mSchedulerDelegate;
......@@ -31,6 +33,12 @@ class BackgroundTaskSchedulerImpl implements BackgroundTaskScheduler {
@Override
public boolean schedule(Context context, TaskInfo taskInfo) {
if (CommandLine.getInstance().hasSwitch(SWITCH_IGNORE_BACKGROUND_TASKS)) {
// When background tasks finish executing, they leave a cached process, which
// artificially inflates startup metrics that are based on events near to process
// creation.
return true;
}
try (TraceEvent te = TraceEvent.scoped(
"BackgroundTaskScheduler.schedule", Integer.toString(taskInfo.getTaskId()))) {
ThreadUtils.assertOnUiThread();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment