Commit f8e6df88 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Remove IncognitoDynamicQuota experiment flag.

Incognito dynamic quota has been enabled by default. The feature and
experimental test code are cleaned up.

Bug: 1017120
Change-Id: I18895ae16dbd2641cf67d8f113b56509da67c7fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2426570Reviewed-by: default avatarJarryd Goodman <jarrydg@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Commit-Queue: Ilya Sherman <isherman@chromium.org>
Auto-Submit: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813936}
parent 86e5c53a
...@@ -8,19 +8,6 @@ namespace storage { ...@@ -8,19 +8,6 @@ namespace storage {
namespace features { namespace features {
// 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_ENABLED_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.15};
constexpr base::FeatureParam<double> kIncognitoQuotaRatioUpperBound{
&kIncognitoDynamicQuota, "IncognitoQuotaRatioUpperBound", 0.2};
// Enables Storage Pressure Event. // Enables Storage Pressure Event.
const base::Feature kStoragePressureEvent{"StoragePressureEvent", const base::Feature kStoragePressureEvent{"StoragePressureEvent",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
......
...@@ -13,11 +13,6 @@ namespace storage { ...@@ -13,11 +13,6 @@ namespace storage {
namespace features { namespace features {
COMPONENT_EXPORT(STORAGE_BROWSER)
extern const base::Feature kIncognitoDynamicQuota;
extern const base::FeatureParam<double> kIncognitoQuotaRatioLowerBound;
extern const base::FeatureParam<double> kIncognitoQuotaRatioUpperBound;
COMPONENT_EXPORT(STORAGE_BROWSER) COMPONENT_EXPORT(STORAGE_BROWSER)
extern const base::Feature kStoragePressureEvent; extern const base::Feature kStoragePressureEvent;
......
...@@ -28,6 +28,8 @@ const int64_t kMBytes = 1024 * 1024; ...@@ -28,6 +28,8 @@ const int64_t kMBytes = 1024 * 1024;
const int kRandomizedPercentage = 10; const int kRandomizedPercentage = 10;
const double kDefaultPerHostRatio = 0.75; const double kDefaultPerHostRatio = 0.75;
const double kDefaultPoolSizeRatio = 0.8; const double kDefaultPoolSizeRatio = 0.8;
const double kIncognitoQuotaRatioLowerBound = 0.15;
const double kIncognitoQuotaRatioUpperBound = 0.2;
// Skews |value| by +/- |percent|. // Skews |value| by +/- |percent|.
int64_t RandomizeByPercent(int64_t value, int percent) { int64_t RandomizeByPercent(int64_t value, int percent) {
...@@ -37,25 +39,15 @@ int64_t RandomizeByPercent(int64_t value, int percent) { ...@@ -37,25 +39,15 @@ int64_t RandomizeByPercent(int64_t value, int percent) {
QuotaSettings CalculateIncognitoDynamicSettings( QuotaSettings CalculateIncognitoDynamicSettings(
int64_t physical_memory_amount) { int64_t physical_memory_amount) {
// The incognito pool size is a fraction of the amount of system memory, // The incognito pool size is a fraction of the amount of system memory.
// and the amount is capped to a hard limit. double incognito_pool_size_ratio =
double incognito_pool_size_ratio = 0.1; // 10% kIncognitoQuotaRatioLowerBound +
int64_t max_incognito_pool_size = 300 * kMBytes; (base::RandDouble() *
if (base::FeatureList::IsEnabled(features::kIncognitoDynamicQuota)) { (kIncognitoQuotaRatioUpperBound - kIncognitoQuotaRatioLowerBound));
const double lower_bound = features::kIncognitoQuotaRatioLowerBound.Get();
const double upper_bound = features::kIncognitoQuotaRatioUpperBound.Get();
incognito_pool_size_ratio =
lower_bound + (base::RandDouble() * (upper_bound - lower_bound));
max_incognito_pool_size = std::numeric_limits<int64_t>::max();
} else {
max_incognito_pool_size =
RandomizeByPercent(max_incognito_pool_size, kRandomizedPercentage);
}
QuotaSettings settings; QuotaSettings settings;
settings.pool_size = std::min( settings.pool_size =
max_incognito_pool_size, static_cast<int64_t>(physical_memory_amount * incognito_pool_size_ratio);
static_cast<int64_t>(physical_memory_amount * incognito_pool_size_ratio));
settings.per_host_quota = settings.pool_size / 3; settings.per_host_quota = settings.pool_size / 3;
settings.session_only_per_host_quota = settings.per_host_quota; settings.session_only_per_host_quota = settings.per_host_quota;
settings.refresh_interval = base::TimeDelta::Max(); settings.refresh_interval = base::TimeDelta::Max();
...@@ -163,4 +155,11 @@ QuotaDeviceInfoHelper* GetDefaultDeviceInfoHelper() { ...@@ -163,4 +155,11 @@ QuotaDeviceInfoHelper* GetDefaultDeviceInfoHelper() {
return singleton.get(); return singleton.get();
} }
double GetIncognitoQuotaRatioLowerBound_ForTesting() {
return kIncognitoQuotaRatioLowerBound;
}
double GetIncognitoQuotaRatioUpperBound_ForTesting() {
return kIncognitoQuotaRatioUpperBound;
}
} // namespace storage } // namespace storage
...@@ -96,6 +96,11 @@ inline QuotaSettings GetHardCodedSettings(int64_t per_host_quota) { ...@@ -96,6 +96,11 @@ inline QuotaSettings GetHardCodedSettings(int64_t per_host_quota) {
per_host_quota, per_host_quota); per_host_quota, per_host_quota);
} }
COMPONENT_EXPORT(STORAGE_BROWSER)
double GetIncognitoQuotaRatioLowerBound_ForTesting();
COMPONENT_EXPORT(STORAGE_BROWSER)
double GetIncognitoQuotaRatioUpperBound_ForTesting();
// Returns object that can fetch actual total disk space; instance lives // Returns object that can fetch actual total disk space; instance lives
// as long as the process is a live. // as long as the process is a live.
COMPONENT_EXPORT(STORAGE_BROWSER) COMPONENT_EXPORT(STORAGE_BROWSER)
......
...@@ -20,16 +20,8 @@ using ::testing::_; ...@@ -20,16 +20,8 @@ using ::testing::_;
namespace { namespace {
constexpr int64_t kMBytes = 1024 * 1024; constexpr int64_t kLowPhysicalMemory = 1024 * 1024;
constexpr int64_t kHighPhysicalMemory = 65536 * kLowPhysicalMemory;
// 10% is the non-experimental incognito pool size ratio
// as defined in storage/browser/quota/quota_settings.cc line 37.
constexpr double kIncognitoPoolSizeRatio = 0.1;
// 300 MB + 10% is the max incognito pool size as set in
// storage/browser/quota/quota_settings.cc line 48.
constexpr int64_t kMaxIncognitoPoolSize =
(300 + 300 * kIncognitoPoolSizeRatio) * kMBytes;
} // namespace } // namespace
...@@ -71,40 +63,18 @@ class QuotaSettingsIncognitoTest : public QuotaSettingsTest { ...@@ -71,40 +63,18 @@ class QuotaSettingsIncognitoTest : public QuotaSettingsTest {
.Times(expected_calls); .Times(expected_calls);
} }
void EnableFeature() { void GetAndTestSettings(const int64_t physical_memory_amount) {
scoped_feature_list_.Reset();
scoped_feature_list_.InitAndEnableFeatureWithParameters(
features::kIncognitoDynamicQuota,
{{"IncognitoQuotaRatioLowerBound", ratio_lower_bound_},
{"IncognitoQuotaRatioUpperBound", ratio_upper_bound_}});
}
void DisableFeature() {
scoped_feature_list_.Reset();
scoped_feature_list_.InitAndDisableFeature(
features::kIncognitoDynamicQuota);
}
void GetAndTestExperimentalSettings(const int64_t physical_memory_amount) {
bool callback_executed = false;
GetNominalDynamicSettings(
profile_path(), true, device_info_helper(),
base::BindLambdaForTesting([&](base::Optional<QuotaSettings> settings) {
callback_executed = true;
EXPECT_LE(physical_memory_amount * 0.2, settings->pool_size);
EXPECT_GE(physical_memory_amount * 0.3, settings->pool_size);
}));
task_environment_.RunUntilIdle();
EXPECT_TRUE(callback_executed);
}
void GetAndTestDefaultSettings() {
bool callback_executed = false; bool callback_executed = false;
GetNominalDynamicSettings( GetNominalDynamicSettings(
profile_path(), true, device_info_helper(), profile_path(), true, device_info_helper(),
base::BindLambdaForTesting([&](base::Optional<QuotaSettings> settings) { base::BindLambdaForTesting([&](base::Optional<QuotaSettings> settings) {
callback_executed = true; callback_executed = true;
EXPECT_GE(kMaxIncognitoPoolSize, settings->pool_size); EXPECT_LE(physical_memory_amount *
GetIncognitoQuotaRatioLowerBound_ForTesting(),
settings->pool_size);
EXPECT_GE(physical_memory_amount *
GetIncognitoQuotaRatioUpperBound_ForTesting(),
settings->pool_size);
})); }));
task_environment_.RunUntilIdle(); task_environment_.RunUntilIdle();
EXPECT_TRUE(callback_executed); EXPECT_TRUE(callback_executed);
...@@ -116,8 +86,6 @@ class QuotaSettingsIncognitoTest : public QuotaSettingsTest { ...@@ -116,8 +86,6 @@ class QuotaSettingsIncognitoTest : public QuotaSettingsTest {
private: private:
MockQuotaDeviceInfoHelper device_info_helper_; MockQuotaDeviceInfoHelper device_info_helper_;
std::string ratio_lower_bound_ = "0.2";
std::string ratio_upper_bound_ = "0.3";
}; };
TEST_F(QuotaSettingsTest, Default) { TEST_F(QuotaSettingsTest, Default) {
...@@ -140,64 +108,18 @@ TEST_F(QuotaSettingsTest, Default) { ...@@ -140,64 +108,18 @@ TEST_F(QuotaSettingsTest, Default) {
EXPECT_TRUE(callback_executed); EXPECT_TRUE(callback_executed);
} }
TEST_F(QuotaSettingsTest, IncognitoQuotaCapped) { TEST_F(QuotaSettingsIncognitoTest, IncognitoDynamicQuota_LowPhysicalMemory) {
MockQuotaDeviceInfoHelper device_info_helper; const int expected_device_info_calls = 1;
EXPECT_CALL(device_info_helper, AmountOfPhysicalMemory()).Times(1);
ON_CALL(device_info_helper, AmountOfPhysicalMemory())
.WillByDefault(::testing::Return(kMaxIncognitoPoolSize));
scoped_feature_list_.InitAndDisableFeature(features::kIncognitoDynamicQuota);
bool callback_executed = false;
GetNominalDynamicSettings(
profile_path(), true, &device_info_helper,
base::BindLambdaForTesting([&](base::Optional<QuotaSettings> settings) {
callback_executed = true;
EXPECT_GE(kMaxIncognitoPoolSize, settings->pool_size);
}));
task_environment_.RunUntilIdle();
EXPECT_TRUE(callback_executed);
}
TEST_F(QuotaSettingsIncognitoTest, IncognitoDynamicQuota_BelowStaticLimit) {
const int expected_device_info_calls = 2;
const int64_t physical_memory_amount = 1000 * kMBytes;
static_assert(
physical_memory_amount * kIncognitoPoolSizeRatio < kMaxIncognitoPoolSize,
"10% of physical_memory_amount should be less than "
"kMaxIncognitoPoolSize");
SetUpDeviceInfoHelper(expected_device_info_calls, physical_memory_amount);
EnableFeature();
GetAndTestExperimentalSettings(physical_memory_amount);
DisableFeature();
GetAndTestDefaultSettings();
}
TEST_F(QuotaSettingsIncognitoTest, IncognitoDynamicQuota_AtStaticLimit) { SetUpDeviceInfoHelper(expected_device_info_calls, kLowPhysicalMemory);
const int expected_device_info_calls = 2; GetAndTestSettings(kLowPhysicalMemory);
const int64_t physical_memory_amount = 3300 * kMBytes;
static_assert(physical_memory_amount * 0.1 == kMaxIncognitoPoolSize,
"10% of physical_memory_amount should be equal to "
"kMaxIncognitoPoolSize");
SetUpDeviceInfoHelper(expected_device_info_calls, physical_memory_amount);
EnableFeature();
GetAndTestExperimentalSettings(physical_memory_amount);
DisableFeature();
GetAndTestDefaultSettings();
} }
TEST_F(QuotaSettingsIncognitoTest, IncognitoDynamicQuota_AboveStaticLimit) { TEST_F(QuotaSettingsIncognitoTest, IncognitoDynamicQuota_HighPhysicalMemory) {
const int expected_device_info_calls = 1; const int expected_device_info_calls = 1;
const int64_t physical_memory_amount = 10000 * kMBytes;
static_assert( SetUpDeviceInfoHelper(expected_device_info_calls, kHighPhysicalMemory);
physical_memory_amount * kIncognitoPoolSizeRatio > kMaxIncognitoPoolSize, GetAndTestSettings(kHighPhysicalMemory);
"10% of physical_memory_amount should "
"be greater than kMaxIncognitoPoolSize");
SetUpDeviceInfoHelper(expected_device_info_calls, physical_memory_amount);
EnableFeature();
GetAndTestExperimentalSettings(physical_memory_amount);
} }
} // namespace storage } // namespace storage
...@@ -3480,30 +3480,6 @@ ...@@ -3480,30 +3480,6 @@
] ]
} }
], ],
"IncognitoDynamicQuota": [
{
"platforms": [
"android",
"android_weblayer",
"chromeos",
"linux",
"mac",
"windows"
],
"experiments": [
{
"name": "WideRange",
"params": {
"IncognitoQuotaRatioLowerBound": "0.1",
"IncognitoQuotaRatioUpperBound": "0.2"
},
"enable_features": [
"IncognitoDynamicQuota"
]
}
]
}
],
"IncompatibleApplicationsWarning": [ "IncompatibleApplicationsWarning": [
{ {
"platforms": [ "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