Add feature to enable/disable Chrome's ADPF usage based on device's SOC [chromium/src : main]

0 views
Skip to first unread message

Kyle Charbonneau (Gerrit)

unread,
Oct 4, 2024, 8:46:53 AM (3 days ago) Oct 4
to Igor Kraskevich, Eric Seckler, Tricium, Chromium LUCI CQ, [email protected], [email protected]
Attention needed from Eric Seckler and Igor Kraskevich

Kyle Charbonneau added 5 comments

File base/system/sys_info.h
Line 131, Patchset 5 (Latest): static std::string SocManufacturer();
Kyle Charbonneau . unresolved

nit: Add a function level description like HardwareModelName() has.

File components/viz/service/performance_hint/hint_session.cc
Line 251, Patchset 5 (Latest): base::SplitString(features::kADPFSocAllowlist.Get(), "|",
Kyle Charbonneau . unresolved

You should be able to use SplitStringPiece() to get std::vector<std::string_view> avoid copies.

Line 259, Patchset 5 (Latest): if (!allowlist.empty() &&
Kyle Charbonneau . unresolved

How about structuring this as:

```
if (allowlist.empty()) {
// check blocklist
} else {
// check allowlist
}
```
Line 260, Patchset 5 (Latest): std::find(allowlist.begin(), allowlist.end(), soc) == allowlist.end()) {
Kyle Charbonneau . unresolved

`std::ranges::contains(allowlist, soc)` is cleaner.

Line 241, Patchset 5 (Latest): if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableAdpf))
return nullptr;
if (base::android::BuildInfo::GetInstance()->sdk_int() <
base::android::SDK_VERSION_S)
return nullptr;
if (!AdpfMethods::Get().supported)
return nullptr;

if (base::FeatureList::IsEnabled(features::kEnableADPFSocFilter)) {
std::vector<std::string> allowlist =
base::SplitString(features::kADPFSocAllowlist.Get(), "|",
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
std::vector<std::string> blocklist =
base::SplitString(features::kADPFSocBlocklist.Get(), "|",
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
std::string soc = base::SysInfo::SocManufacturer();
// If there's an allowlist, soc must be in the allowlist.
// Blocklist is ignored in this case.
if (!allowlist.empty() &&
std::find(allowlist.begin(), allowlist.end(), soc) == allowlist.end()) {
return nullptr;
}
// If there's no allowlist, soc must be absent from the blocklist.
if (allowlist.empty() &&
std::find(blocklist.begin(), blocklist.end(), soc) != blocklist.end()) {
return nullptr;
}
}
Kyle Charbonneau . unresolved

Maybe all of this can go in `IsAdpfEnabled()` helper in viz/common/features? That would be similar to the other feature block listing code like for [vulkan](https://source.chromium.org/chromium/chromium/src/+/main:gpu/config/gpu_finch_features.cc;l=424-476;drc=11a0f1ec382c206d39bd7d5cd59f5a087a69bd7c) and avoid having to export the base::FeatureParams. Alternatively a helper function in this file would be good just to separate this logic (especially when it inevitably grows at some point in the future)

Open in Gerrit

Related details

Attention is currently required from:
  • Eric Seckler
  • Igor Kraskevich
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I59e99b3c792d3a8b55beb01fac67219c2d335396
Gerrit-Change-Number: 5909372
Gerrit-PatchSet: 5
Gerrit-Owner: Igor Kraskevich <[email protected]>
Gerrit-Reviewer: Eric Seckler <[email protected]>
Gerrit-Reviewer: Igor Kraskevich <[email protected]>
Gerrit-Reviewer: Kyle Charbonneau <[email protected]>
Gerrit-CC: Chromium LUCI CQ <[email protected]>
Gerrit-CC: Tricium <[email protected]>
Gerrit-CC: [email protected]
Gerrit-Attention: Igor Kraskevich <[email protected]>
Gerrit-Attention: Eric Seckler <[email protected]>
Gerrit-Comment-Date: Fri, 04 Oct 2024 15:46:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Eric Seckler (Gerrit)

unread,
Oct 4, 2024, 9:07:26 AM (3 days ago) Oct 4
to Igor Kraskevich, Kyle Charbonneau, Tricium, Chromium LUCI CQ, [email protected], [email protected]
Attention needed from Igor Kraskevich

Eric Seckler added 1 comment

File components/viz/common/features.cc
Line 335, Patchset 5 (Latest):BASE_FEATURE(kEnableADPFSocFilter,
Eric Seckler . unresolved

WDYT about making this just kAdpf with the params below? So enabling the feature enables ADPF (optionally with the blocklist/allowlist filters), and disabling it turns it off.

We can discuss if enabling or disabling ADPF by default is the right strategy though ;)

Open in Gerrit

Related details

Attention is currently required from:
  • Igor Kraskevich
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I59e99b3c792d3a8b55beb01fac67219c2d335396
Gerrit-Change-Number: 5909372
Gerrit-PatchSet: 5
Gerrit-Owner: Igor Kraskevich <[email protected]>
Gerrit-Reviewer: Eric Seckler <[email protected]>
Gerrit-Reviewer: Igor Kraskevich <[email protected]>
Gerrit-Reviewer: Kyle Charbonneau <[email protected]>
Gerrit-CC: Chromium LUCI CQ <[email protected]>
Gerrit-CC: Tricium <[email protected]>
Gerrit-CC: [email protected]
Gerrit-Attention: Igor Kraskevich <[email protected]>
Gerrit-Comment-Date: Fri, 04 Oct 2024 16:07:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Igor Kraskevich (Gerrit)

unread,
4:23 AM (2 hours ago) 4:23 AM
to Kyle Charbonneau, Eric Seckler, Tricium, Chromium LUCI CQ, [email protected], [email protected]
Attention needed from Eric Seckler and Kyle Charbonneau

Igor Kraskevich voted and added 6 comments

Votes added by Igor Kraskevich

Commit-Queue+1

6 comments

File base/system/sys_info.h
Line 131, Patchset 5: static std::string SocManufacturer();
Kyle Charbonneau . resolved

nit: Add a function level description like HardwareModelName() has.

Igor Kraskevich

Done

File components/viz/common/features.cc
Line 335, Patchset 5:BASE_FEATURE(kEnableADPFSocFilter,
Eric Seckler . unresolved

WDYT about making this just kAdpf with the params below? So enabling the feature enables ADPF (optionally with the blocklist/allowlist filters), and disabling it turns it off.

We can discuss if enabling or disabling ADPF by default is the right strategy though ;)

Igor Kraskevich

I don't mind calling it `kAdpf` - I've changed the name and the behavior when the feature is disabled.

I think it has to be enabled by default, and having neither an allowlist nor a blocklist has to imply enabled ADPF - otherwise we're going to change the default Chrome behavior on all devices for the next release (unless we time the server side config changes right, but this is too risky and I'd rather not do this).

File components/viz/service/performance_hint/hint_session.cc
Line 251, Patchset 5: base::SplitString(features::kADPFSocAllowlist.Get(), "|",
Kyle Charbonneau . resolved

You should be able to use SplitStringPiece() to get std::vector<std::string_view> avoid copies.

Igor Kraskevich

Done

Line 259, Patchset 5: if (!allowlist.empty() &&
Kyle Charbonneau . unresolved

How about structuring this as:

```
if (allowlist.empty()) {
// check blocklist
} else {
// check allowlist
}
```
Igor Kraskevich
Now that this logic is in a helper function I've changed it to:
```
if (allowlist.empty()) {
return X;
}
return Y;
```
Line 260, Patchset 5: std::find(allowlist.begin(), allowlist.end(), soc) == allowlist.end()) {
Kyle Charbonneau . unresolved

`std::ranges::contains(allowlist, soc)` is cleaner.

Igor Kraskevich

This doesn't compile - `error: no member named 'contains' in namespace 'std::ranges'` (I have added the right header). Given that I don't see any examples of this in chromium I presume that it needs a newer compiler.

`base::Contains` works, so I've used it instead.

Line 241, Patchset 5: if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableAdpf))
Igor Kraskevich

I've create a local helper - PTAL.

Open in Gerrit

Related details

Attention is currently required from:
  • Eric Seckler
  • Kyle Charbonneau
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I59e99b3c792d3a8b55beb01fac67219c2d335396
Gerrit-Change-Number: 5909372
Gerrit-PatchSet: 8
Gerrit-Owner: Igor Kraskevich <[email protected]>
Gerrit-Reviewer: Eric Seckler <[email protected]>
Gerrit-Reviewer: Igor Kraskevich <[email protected]>
Gerrit-Reviewer: Kyle Charbonneau <[email protected]>
Gerrit-CC: Chromium LUCI CQ <[email protected]>
Gerrit-CC: Tricium <[email protected]>
Gerrit-CC: [email protected]
Gerrit-Attention: Eric Seckler <[email protected]>
Gerrit-Attention: Kyle Charbonneau <[email protected]>
Gerrit-Comment-Date: Mon, 07 Oct 2024 11:23:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Eric Seckler <[email protected]>
Comment-In-Reply-To: Kyle Charbonneau <[email protected]>
satisfied_requirement
unsatisfied_requirement
open
diffy

Eric Seckler (Gerrit)

unread,
5:09 AM (1 hour ago) 5:09 AM
to Igor Kraskevich, Kyle Charbonneau, Tricium, Chromium LUCI CQ, [email protected], [email protected]
Attention needed from Igor Kraskevich and Kyle Charbonneau

Eric Seckler added 2 comments

File components/viz/common/features.cc
Line 313, Patchset 9 (Latest):const base::FeatureParam<std::string> kADPFSocAllowlist{
Eric Seckler . unresolved

Let's put a comment here that this is about SoC makes (rather than models).

Line 314, Patchset 9 (Latest): &kAdpf, "adpf_soc_allowlist", ""};
Eric Seckler . unresolved

How about we make this "Google" by default? That way we don't change the behavior for Pixels but are reverting to rollout-per-SoC manufacturer for now, which seems safer than what we do today.

Yes it's a breaking change, but it feels like we should test it out elsewhere first and then explicitly decide to roll it to those SoC makes, given the regressions and issues we know of with other SoC makes so far. WDYT?

Open in Gerrit

Related details

Attention is currently required from:
  • Igor Kraskevich
  • Kyle Charbonneau
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I59e99b3c792d3a8b55beb01fac67219c2d335396
Gerrit-Change-Number: 5909372
Gerrit-PatchSet: 9
Gerrit-Owner: Igor Kraskevich <[email protected]>
Gerrit-Reviewer: Eric Seckler <[email protected]>
Gerrit-Reviewer: Igor Kraskevich <[email protected]>
Gerrit-Reviewer: Kyle Charbonneau <[email protected]>
Gerrit-CC: Chromium LUCI CQ <[email protected]>
Gerrit-CC: Tricium <[email protected]>
Gerrit-CC: [email protected]
Gerrit-Attention: Igor Kraskevich <[email protected]>
Gerrit-Attention: Kyle Charbonneau <[email protected]>
Gerrit-Comment-Date: Mon, 07 Oct 2024 12:09:15 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Igor Kraskevich (Gerrit)

unread,
5:44 AM (1 hour ago) 5:44 AM
to Kyle Charbonneau, Eric Seckler, Tricium, Chromium LUCI CQ, [email protected], [email protected]
Attention needed from Eric Seckler and Kyle Charbonneau

Igor Kraskevich added 2 comments

File components/viz/common/features.cc
Line 313, Patchset 9:const base::FeatureParam<std::string> kADPFSocAllowlist{
Eric Seckler . unresolved

Let's put a comment here that this is about SoC makes (rather than models).

Igor Kraskevich

There's a sentence "if the device's SOC manufacturer satisifes the allowlist and blocklist rules". I think this is enough to tell that this about makes rather then models?

Line 314, Patchset 9: &kAdpf, "adpf_soc_allowlist", ""};
Eric Seckler . resolved

How about we make this "Google" by default? That way we don't change the behavior for Pixels but are reverting to rollout-per-SoC manufacturer for now, which seems safer than what we do today.

Yes it's a breaking change, but it feels like we should test it out elsewhere first and then explicitly decide to roll it to those SoC makes, given the regressions and issues we know of with other SoC makes so far. WDYT?

Igor Kraskevich

I've changed it to "Google".

Open in Gerrit

Related details

Attention is currently required from:
  • Eric Seckler
  • Kyle Charbonneau
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I59e99b3c792d3a8b55beb01fac67219c2d335396
Gerrit-Change-Number: 5909372
Gerrit-PatchSet: 11
Gerrit-Owner: Igor Kraskevich <[email protected]>
Gerrit-Reviewer: Eric Seckler <[email protected]>
Gerrit-Reviewer: Igor Kraskevich <[email protected]>
Gerrit-Reviewer: Kyle Charbonneau <[email protected]>
Gerrit-CC: Chromium LUCI CQ <[email protected]>
Gerrit-CC: Tricium <[email protected]>
Gerrit-CC: [email protected]
Gerrit-Attention: Eric Seckler <[email protected]>
Gerrit-Attention: Kyle Charbonneau <[email protected]>
Gerrit-Comment-Date: Mon, 07 Oct 2024 12:44:25 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Eric Seckler <[email protected]>
satisfied_requirement
unsatisfied_requirement
open
diffy

Igor Kraskevich (Gerrit)

unread,
6:11 AM (24 minutes ago) 6:11 AM
to Kyle Charbonneau, Eric Seckler, Tricium, Chromium LUCI CQ, [email protected], [email protected]
Attention needed from Eric Seckler and Kyle Charbonneau

Igor Kraskevich added 1 comment

File components/viz/common/features.cc
Line 335, Patchset 5:BASE_FEATURE(kEnableADPFSocFilter,
Eric Seckler . unresolved

WDYT about making this just kAdpf with the params below? So enabling the feature enables ADPF (optionally with the blocklist/allowlist filters), and disabling it turns it off.

We can discuss if enabling or disabling ADPF by default is the right strategy though ;)

Igor Kraskevich

I don't mind calling it `kAdpf` - I've changed the name and the behavior when the feature is disabled.

I think it has to be enabled by default, and having neither an allowlist nor a blocklist has to imply enabled ADPF - otherwise we're going to change the default Chrome behavior on all devices for the next release (unless we time the server side config changes right, but this is too risky and I'd rather not do this).

Igor Kraskevich

As discussed in the other comment thread - making the "adpf_soc_allowlist" default value "Google" should be fine.

Gerrit-Comment-Date: Mon, 07 Oct 2024 13:11:01 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Igor Kraskevich <[email protected]>
Comment-In-Reply-To: Eric Seckler <[email protected]>
satisfied_requirement
unsatisfied_requirement
open
diffy

Kyle Charbonneau (Gerrit)

unread,
6:31 AM (4 minutes ago) 6:31 AM
to Igor Kraskevich, Eric Seckler, Tricium, Chromium LUCI CQ, [email protected], [email protected]
Attention needed from Eric Seckler and Igor Kraskevich

Kyle Charbonneau voted and added 5 comments

Votes added by Kyle Charbonneau

Code-Review+1

5 comments

Patchset-level comments
File-level comment, Patchset 11 (Latest):
Kyle Charbonneau . resolved

lgtm

File components/viz/service/performance_hint/hint_session.cc
Line 259, Patchset 5: if (!allowlist.empty() &&
Kyle Charbonneau . resolved

How about structuring this as:

```
if (allowlist.empty()) {
// check blocklist
} else {
// check allowlist
}
```
Igor Kraskevich
Now that this logic is in a helper function I've changed it to:
```
if (allowlist.empty()) {
return X;
}
return Y;
```
Kyle Charbonneau

Acknowledged

Line 260, Patchset 5: std::find(allowlist.begin(), allowlist.end(), soc) == allowlist.end()) {
Kyle Charbonneau . resolved

`std::ranges::contains(allowlist, soc)` is cleaner.

Igor Kraskevich

This doesn't compile - `error: no member named 'contains' in namespace 'std::ranges'` (I have added the right header). Given that I don't see any examples of this in chromium I presume that it needs a newer compiler.

`base::Contains` works, so I've used it instead.

Kyle Charbonneau

Yes my mistake, base::Contains() is the right thing to use now. std::ranges::contains() is C++23.

Line 241, Patchset 5: if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableAdpf))
return nullptr;
if (base::android::BuildInfo::GetInstance()->sdk_int() <
base::android::SDK_VERSION_S)
return nullptr;
if (!AdpfMethods::Get().supported)
return nullptr;

if (base::FeatureList::IsEnabled(features::kEnableADPFSocFilter)) {
std::vector<std::string> allowlist =
base::SplitString(features::kADPFSocAllowlist.Get(), "|",
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
std::vector<std::string> blocklist =
base::SplitString(features::kADPFSocBlocklist.Get(), "|",
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
std::string soc = base::SysInfo::SocManufacturer();
// If there's an allowlist, soc must be in the allowlist.
// Blocklist is ignored in this case.
if (!allowlist.empty() &&
std::find(allowlist.begin(), allowlist.end(), soc) == allowlist.end()) {
return nullptr;
}
// If there's no allowlist, soc must be absent from the blocklist.
if (allowlist.empty() &&
std::find(blocklist.begin(), blocklist.end(), soc) != blocklist.end()) {
return nullptr;
}
}
Kyle Charbonneau . resolved

Maybe all of this can go in `IsAdpfEnabled()` helper in viz/common/features? That would be similar to the other feature block listing code like for [vulkan](https://source.chromium.org/chromium/chromium/src/+/main:gpu/config/gpu_finch_features.cc;l=424-476;drc=11a0f1ec382c206d39bd7d5cd59f5a087a69bd7c) and avoid having to export the base::FeatureParams. Alternatively a helper function in this file would be good just to separate this logic (especially when it inevitably grows at some point in the future)

Igor Kraskevich

I've create a local helper - PTAL.

Kyle Charbonneau

Looks good to me.

Line 264, Patchset 11 (Latest): if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableAdpf))

return nullptr;
if (base::android::BuildInfo::GetInstance()->sdk_int() <
base::android::SDK_VERSION_S)
return nullptr;
if (!AdpfMethods::Get().supported)
return nullptr;
Kyle Charbonneau . unresolved

Totally optional but these could also go in `IsAdpfEnabled()` if the helper was named that.

Open in Gerrit

Related details

Attention is currently required from:
  • Eric Seckler
  • Igor Kraskevich
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I59e99b3c792d3a8b55beb01fac67219c2d335396
Gerrit-Change-Number: 5909372
Gerrit-PatchSet: 11
Gerrit-Owner: Igor Kraskevich <[email protected]>
Gerrit-Reviewer: Eric Seckler <[email protected]>
Gerrit-Reviewer: Igor Kraskevich <[email protected]>
Gerrit-Reviewer: Kyle Charbonneau <[email protected]>
Gerrit-CC: Chromium LUCI CQ <[email protected]>
Gerrit-CC: Tricium <[email protected]>
Gerrit-CC: [email protected]
Gerrit-Attention: Igor Kraskevich <[email protected]>
Gerrit-Attention: Eric Seckler <[email protected]>
Gerrit-Comment-Date: Mon, 07 Oct 2024 13:31:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Igor Kraskevich <[email protected]>
Comment-In-Reply-To: Kyle Charbonneau <[email protected]>
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages