Commit 2d2a2dc8 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Make incognito quota dynamic.

The hard limit for incognito quota is removed and the quota is
dynamically set based on a Finch controllable ratio of the amount of
physical memory.

Bug: 1017120
Change-Id: I218295f661a9080b61bfd0e1487f58678e3bfe1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1878190
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarJarryd Goodman <jarrydg@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710710}
parent e10916f5
......@@ -30,5 +30,19 @@ const base::Feature kStaticHostQuota{"StaticHostQuota",
// removing limits on how much disk space the temporary pool can consume.
const base::Feature kQuotaUnlimitedPoolSize{"QuotaUnlimitedPoolSize",
base::FEATURE_DISABLED_BY_DEFAULT};
// IncognitoDynamicQuota enables dynamic assignment of quota to incognito mode
// based on the physical memory size and removes the fixed upper cap for it.
const base::Feature kIncognitoDynamicQuota{"IncognitoDynamicQuota",
base::FEATURE_DISABLED_BY_DEFAULT};
// Dynamic quota for incognito mode would be set by a random fraction of
// physical memory, between |IncognitoQuotaRatioLowerBound| and
// |IncognitoQuotaRatioUpperBound|.
constexpr base::FeatureParam<double> kIncognitoQuotaRatioLowerBound{
&kIncognitoDynamicQuota, "IncognitoQuotaRatioLowerBound", 0.1};
constexpr base::FeatureParam<double> kIncognitoQuotaRatioUpperBound{
&kIncognitoDynamicQuota, "IncognitoQuotaRatioUpperBound", 0.2};
} // namespace features
} // namespace storage
......@@ -24,6 +24,11 @@ extern const base::Feature kStaticHostQuota;
COMPONENT_EXPORT(STORAGE_BROWSER)
extern const base::Feature kQuotaUnlimitedPoolSize;
COMPONENT_EXPORT(STORAGE_BROWSER)
extern const base::Feature kIncognitoDynamicQuota;
extern const base::FeatureParam<double> kIncognitoQuotaRatioLowerBound;
extern const base::FeatureParam<double> kIncognitoQuotaRatioUpperBound;
} // namespace features
} // namespace storage
......
......@@ -39,14 +39,24 @@ base::Optional<storage::QuotaSettings> CalculateNominalDynamicSettings(
if (is_incognito) {
// The incognito pool size is a fraction of the amount of system memory,
// and the amount is capped to a hard limit.
const double kIncognitoPoolSizeRatio = 0.1; // 10%
const int64_t kMaxIncognitoPoolSize = 300 * kMBytes;
double kIncognitoPoolSizeRatio = 0.1; // 10%
int64_t kMaxIncognitoPoolSize = 300 * kMBytes;
if (base::FeatureList::IsEnabled(features::kIncognitoDynamicQuota)) {
const double lower_bound = features::kIncognitoQuotaRatioLowerBound.Get();
const double upper_bound = features::kIncognitoQuotaRatioUpperBound.Get();
kIncognitoPoolSizeRatio =
lower_bound + (base::RandDouble() * (upper_bound - lower_bound));
kMaxIncognitoPoolSize = std::numeric_limits<int64_t>::max();
} else {
kMaxIncognitoPoolSize =
RandomizeByPercent(kMaxIncognitoPoolSize, kRandomizedPercentage);
}
storage::QuotaSettings settings;
settings.pool_size = std::min(
RandomizeByPercent(kMaxIncognitoPoolSize, kRandomizedPercentage),
static_cast<int64_t>(base::SysInfo::AmountOfPhysicalMemory() *
kIncognitoPoolSizeRatio));
settings.pool_size =
std::min(kMaxIncognitoPoolSize,
static_cast<int64_t>(base::SysInfo::AmountOfPhysicalMemory() *
kIncognitoPoolSizeRatio));
settings.per_host_quota = settings.pool_size / 3;
settings.session_only_per_host_quota = settings.per_host_quota;
settings.refresh_interval = base::TimeDelta::Max();
......
......@@ -2997,6 +2997,29 @@
]
}
],
"IncognitoDynamicQuota": [
{
"platforms": [
"android",
"chromeos",
"linux",
"mac",
"windows"
],
"experiments": [
{
"name": "WideRange",
"params": {
"RatioLowerBound": "0.1",
"RatioUpperBound": "0.2"
},
"enable_features": [
"IncognitoDynamicQuota"
]
}
]
}
],
"IncognitoWindowInProductHelp": [
{
"platforms": [
......
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