Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit 979b218. Reason for revert: Main suspect for causing a build breakage at https://ci.chromium.org/ui/p/chromium/builders/ci/chromeos-octopus-rel/8968/overview Original change's description: > Remove TabRanker. > > It is not used. > > Bug: 784639 > Change-Id: Idd4dc6f0dd8603d3e51b671aab68d761c90580f1 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4064839 > Reviewed-by: Charles Zhao <charleszhao@chromium.org> > Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org> > Commit-Queue: Francois Pierre Doray <fdoray@chromium.org> > Cr-Commit-Position: refs/heads/main@{#1084960} Bug: 784639 Change-Id: I735b21c09f9af16a3e6f840d851ae287a2bf9c32 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4116477 Owners-Override: Łukasz Anforowicz <lukasza@chromium.org> Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org> Reviewed-by: Iman Saboori <isaboori@google.com> Reviewed-by: Francois Pierre Doray <fdoray@chromium.org> Cr-Commit-Position: refs/heads/main@{#1085045}
- Loading branch information
1 parent
ac13ecf
commit 0e4647c
Showing
29 changed files
with
7,343 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
chrome/browser/resource_coordinator/tab_metrics_event.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright 2017 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
syntax = "proto2"; | ||
|
||
option optimize_for = LITE_RUNTIME; | ||
|
||
package metrics; | ||
|
||
// Defines specialized fields used by the TabManager.TabMetrics UKM event. | ||
message TabMetricsEvent { | ||
// Represents the MIME type of content. | ||
// MIME type strings have the format "<type>/<subtype>". The values for | ||
// ContentType reflect just the top-level type (e.g., AUDIO is used for both | ||
// "audio/mp3" and "audio/ogg"). | ||
// The exception is "text/html", since it's treated quite differently than | ||
// other text. | ||
enum ContentType { | ||
// Could not be determined or not available. | ||
CONTENT_TYPE_UNKNOWN = 0; | ||
|
||
// Not one of the types below. | ||
CONTENT_TYPE_OTHER = 1; | ||
|
||
// The "application/*" type. Supported application sub-types are enumerated | ||
// in Chrome's PluginType. | ||
CONTENT_TYPE_APPLICATION = 2; | ||
|
||
// The "audio/*" type. | ||
CONTENT_TYPE_AUDIO = 3; | ||
|
||
// The "image/*" type. | ||
CONTENT_TYPE_IMAGE = 4; | ||
|
||
// The "text/*" type. For "text/html", TEXT_HTML is used instead. | ||
CONTENT_TYPE_TEXT = 5; | ||
|
||
// The "text/html" type, representing web pages. | ||
CONTENT_TYPE_TEXT_HTML = 6; | ||
|
||
// The "video/*" type. | ||
CONTENT_TYPE_VIDEO = 7; | ||
} | ||
|
||
optional ContentType content_type = 1; | ||
} | ||
|
||
// Defines specialized fields used by the TabManager.WindowMetrics UKM event | ||
// for describing the window used by a set of tabs. | ||
message WindowMetricsEvent { | ||
// Represents the type of the window. | ||
enum Type { | ||
// Could not be determined or not available. | ||
TYPE_UNKNOWN = 0; | ||
|
||
// A normal browser window with a tab strip. | ||
TYPE_TABBED = 1; | ||
|
||
// A pop-up browser window with no tab strip. | ||
TYPE_POPUP = 2; | ||
|
||
// An Extension browser window that is not an AppWindow. | ||
TYPE_EXTENSION = 3; | ||
|
||
// An AppWindow for a platform app. | ||
TYPE_APP = 4; | ||
} | ||
|
||
optional Type type = 1; | ||
|
||
// Represents the show state of the window. | ||
enum ShowState { | ||
SHOW_STATE_UNKNOWN = 0; | ||
SHOW_STATE_NORMAL = 1; | ||
SHOW_STATE_MINIMIZED = 2; | ||
SHOW_STATE_MAXIMIZED = 3; | ||
SHOW_STATE_FULLSCREEN = 4; | ||
} | ||
|
||
optional ShowState show_state = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright 2018 The Chromium Authors | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
source_set("tab_ranker") { | ||
# Dependent targets should not include native_inference.h directly. | ||
public = [ | ||
"mru_features.h", | ||
"tab_features.h", | ||
"tab_score_predictor.h", | ||
"window_features.h", | ||
] | ||
|
||
sources = [ | ||
"native_inference.cc", | ||
"native_inference.h", | ||
"pairwise_inference.cc", | ||
"pairwise_inference.h", | ||
"tab_features.cc", | ||
"tab_score_predictor.cc", | ||
"window_features.cc", | ||
] | ||
|
||
public_deps = [ "//base" ] | ||
|
||
deps = [ | ||
"//chrome/browser:resources", | ||
"//chrome/browser/resource_coordinator:tab_manager_features", | ||
"//chrome/browser/resource_coordinator:tab_metrics_event_proto", | ||
"//components/assist_ranker", | ||
"//components/assist_ranker/proto", | ||
"//components/sessions", | ||
"//services/metrics/public/cpp:ukm_builders", | ||
] | ||
} | ||
|
||
# target for using GetFullTabFeaturesForTesting in unit tests. | ||
static_library("tab_features_test_helper") { | ||
testonly = true | ||
sources = [ | ||
"tab_features_test_helper.cc", | ||
"tab_features_test_helper.h", | ||
] | ||
|
||
deps = [ ":tab_ranker" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
amoylan@chromium.org | ||
charleszhao@chromium.org | ||
michaelpg@chromium.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Tab Ranker | ||
|
||
The Tab Ranker is an experimental model used to predict tab reactivation. We | ||
are setting up experiments to use this model as a factor in deciding which tabs | ||
to discard when the system is low on memory. | ||
|
||
## Model | ||
|
||
The input to the model is a list of metrics about a background tab, such as | ||
whether it is pinned, how long it has been in the background, and how many | ||
events it has received. The output is a floating point value, where a higher | ||
number suggests the tab is more likely to be reactivated than a lower number. | ||
The range of possible outputs is dependent on the model; what matters is the | ||
relative ordering of scores, not the precise value of a score. | ||
|
||
The metrics used for inference are the same metrics logged to UKM by | ||
TabMetricsLogger. Using these metrics, we trained a | ||
[DNN](https://en.wikipedia.org/wiki/Deep_learning#Deep_neural_networks) model. | ||
The inferencing code in `native_inference.cc` consists of the model weights | ||
generated by TensorFlow and basic operations to execute the model over an | ||
example. | ||
|
||
See [native_inference.md] for details on how the tf.native code is cleaned up | ||
for Chromium. | ||
|
||
## Example preprocessing | ||
|
||
Examples are provided to the model as an array of floats, with each element | ||
corresponding to a feature. For scalar metrics like WasRecentlyActive(), this | ||
feature is simply a 0 or 1. | ||
|
||
A metric with multiple possible values, like an enum or bucketized number, is | ||
broken into a number of features, each corresponding to one of its possible | ||
values. For example, a value of 7 for the PageTransitionCoreType metric is | ||
represented as a 1 in the `PageTransitionCoreType_7` feature. See | ||
https://en.wikipedia.org/wiki/One-hot. | ||
|
||
The AssistRanker handles this example preprocessing based on the configuration | ||
provided in example_preprocessor_config.pb. This can be examined with the | ||
`print_example_preprocessor_config.py` utility: | ||
|
||
``` | ||
./components/assist_ranker/print_example_preprocessor_config.py \ | ||
out/Release \ | ||
chrome/browser/resource_coordinator/tab_ranker/example_preprocessor_config.pb | ||
``` | ||
|
||
## Scoring a tab | ||
|
||
Use `TabActivityWatcher::CalculateReactivationScore()` to get a score from a | ||
WebContents. | ||
|
||
Internally, `TabScorePredictor::ScoreTab` is the interface to the model. The | ||
caller needs to track a number of metrics about the tab and its window. These | ||
metrics must be calculated in the same way they were logged, as otherwise the | ||
results will not be valid. |
Binary file added
BIN
+9.15 KB
chrome/browser/resource_coordinator/tab_ranker/example_preprocessor_config.pb
Binary file not shown.
25 changes: 25 additions & 0 deletions
25
chrome/browser/resource_coordinator/tab_ranker/mru_features.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2018 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_RANKER_MRU_FEATURES_H_ | ||
#define CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_RANKER_MRU_FEATURES_H_ | ||
|
||
#include <stdint.h> | ||
|
||
namespace tab_ranker { | ||
|
||
// Identifies how recently the tab was used. | ||
struct MRUFeatures { | ||
// Zero-based, so this indicates how many of the |total| tabs are more | ||
// recently used than this tab. | ||
int index = 0; | ||
|
||
// Total number of tabs considered when calculating MRU index, ie number of | ||
// non-incognito tabs open. | ||
int total = 0; | ||
}; | ||
|
||
} // namespace tab_ranker | ||
|
||
#endif // CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_RANKER_MRU_FEATURES_H_ |
Oops, something went wrong.