Skip to content

Commit

Permalink
Quota: Add experimental logic for quota pool size expansion.
Browse files Browse the repository at this point in the history
Bug: 919693
Change-Id: I99bebbbccf7d57a711e4305faa5a57c01a1e39f5
Reviewed-on: https://chromium-review.googlesource.com/c/1401568
Reviewed-by: Victor Costan <pwnall@chromium.org>
Reviewed-by: Steven Holte <holte@chromium.org>
Commit-Queue: Jarryd Goodman <jarrydg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625543}
  • Loading branch information
Jarryd authored and Commit Bot committed Jan 24, 2019
1 parent b03357d commit 7a79f06
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 14 deletions.
2 changes: 2 additions & 0 deletions storage/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ jumbo_component("browser") {
"quota/quota_client.h",
"quota/quota_database.cc",
"quota/quota_database.h",
"quota/quota_features.cc",
"quota/quota_features.h",
"quota/quota_macros.h",
"quota/quota_manager.cc",
"quota/quota_manager.h",
Expand Down
31 changes: 31 additions & 0 deletions storage/browser/quota/quota_features.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "storage/browser/quota/quota_features.h"

namespace storage {

namespace features {

#if defined(OS_CHROMEOS)
// Chrome OS is given a larger fraction, as web content is the considered
// the primary use of the platform. Chrome OS itself maintains free space by
// starting to evict data (old profiles) when less than 1GB remains,
// stopping eviction once 2GB is free.
// Prior to M66 this was 1/3, same as other platforms.
const constexpr double kTemporaryPoolSizeRatioThirds = 2.0 / 3.0; // 66%
#else
const constexpr double kTemporaryPoolSizeRatioThirds = 1.0 / 3.0; // 33%
#endif

const base::Feature kQuotaExpandPoolSize{"QuotaExpandPoolSize",
base::FEATURE_DISABLED_BY_DEFAULT};

constexpr base::FeatureParam<double> kExperimentalPoolSizeRatio{
&kQuotaExpandPoolSize, "PoolSizeRatio", kTemporaryPoolSizeRatioThirds};

constexpr base::FeatureParam<double> kPerHostRatio{&kQuotaExpandPoolSize,
"PerHostRatio", 0.2};
} // namespace features
} // namespace storage
25 changes: 25 additions & 0 deletions storage/browser/quota/quota_features.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef STORAGE_BROWSER_QUOTA_QUOTA_FEATURES_H_
#define STORAGE_BROWSER_QUOTA_QUOTA_FEATURES_H_

#include "base/component_export.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"

namespace storage {

namespace features {

COMPONENT_EXPORT(STORAGE_BROWSER)
extern const base::Feature kQuotaExpandPoolSize;
extern const base::FeatureParam<double> kExperimentalPoolSizeRatio;
extern const base::FeatureParam<double> kPerHostRatio;

} // namespace features

} // namespace storage

#endif // STORAGE_QUOTA_QUOTA_FEATURES_H_
24 changes: 10 additions & 14 deletions storage/browser/quota/quota_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/task/post_task.h"
#include "base/threading/scoped_blocking_call.h"
#include "build/build_config.h"
#include "storage/browser/quota/quota_features.h"
#include "storage/browser/quota/quota_macros.h"

namespace storage {
Expand Down Expand Up @@ -47,18 +48,13 @@ base::Optional<storage::QuotaSettings> CalculateNominalDynamicSettings(
return settings;
}

// The fraction of the device's storage the browser is willing to
// use for temporary storage.
#if defined(OS_CHROMEOS)
// Chrome OS is given a larger fraction, as web content is the considered
// the primary use of the platform. Chrome OS itself maintains free space by
// starting to evict data (old profiles) when less than 1GB remains,
// stopping eviction once 2GB is free.
// Prior to M66 this was 1/3, same as other platforms.
const double kTemporaryPoolSizeRatio = 2.0 / 3.0; // 66%
#else
const double kTemporaryPoolSizeRatio = 1.0 / 3.0; // 33%
#endif
// The fraction of the device's storage the browser is willing to
// use for temporary storage.
// Check Finch for an experimental value to use as temporary pool size ratio
// if experiment is enabled, otherwise fallback to ~66% for chromeOS and
// ~33% otherwise.
const double kTemporaryPoolSizeRatio =
features::kExperimentalPoolSizeRatio.Get();

// The amount of the device's storage the browser attempts to
// keep free. If there is less than this amount of storage free
Expand Down Expand Up @@ -93,7 +89,7 @@ base::Optional<storage::QuotaSettings> CalculateNominalDynamicSettings(

// Determines the portion of the temp pool that can be
// utilized by a single host (ie. 5 for 20%).
const int kPerHostTemporaryPortion = 5;
const double kPerHostTemporaryRatio = features::kPerHostRatio.Get();

// SessionOnly (or ephemeral) origins are allotted a fraction of what
// normal origins are provided, and the amount is capped to a hard limit.
Expand All @@ -117,7 +113,7 @@ base::Optional<storage::QuotaSettings> CalculateNominalDynamicSettings(
settings.must_remain_available =
std::min(kMustRemainAvailableFixed,
static_cast<int64_t>(total * kMustRemainAvailableRatio));
settings.per_host_quota = pool_size / kPerHostTemporaryPortion;
settings.per_host_quota = pool_size * kPerHostTemporaryRatio;
settings.session_only_per_host_quota = std::min(
RandomizeByPercent(kMaxSessionOnlyHostQuota, kRandomizedPercentage),
static_cast<int64_t>(settings.per_host_quota *
Expand Down
103 changes: 103 additions & 0 deletions testing/variations/fieldtrial_testing_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3748,6 +3748,109 @@
]
}
],
"QuotaExpandPoolSize": [
{
"platforms": [
"android",
"ios",
"linux",
"mac",
"windows"
],
"experiments": [
{
"name": "Enabled_Pool_TwoThirds_Origin_OneFifth",
"params": {
"PerHostPortion": "0.2",
"PoolSizeRatio": "0.6666666666666666"
},
"enable_features": [
"QuotaExpandPoolSize"
]
},
{
"name": "Enabled_Pool_ThreeQuarters_Origin_OneFifth",
"params": {
"PerHostPortion": "0.2",
"PoolSizeRatio": "0.75"
},
"enable_features": [
"QuotaExpandPoolSize"
]
},
{
"name": "Enabled_Pool_Full_Origin_OneFifth",
"params": {
"PerHostPortion": "0.2",
"PoolSizeRatio": "1.0"
},
"enable_features": [
"QuotaExpandPoolSize"
]
},
{
"name": "Enabled_Pool_TwoThirds_Origin_OneHalf",
"params": {
"PerHostPortion": "0.5",
"PoolSizeRatio": "0.6666666666666666"
},
"enable_features": [
"QuotaExpandPoolSize"
]
},
{
"name": "Enabled_Pool_ThreeQuarters_Origin_OneHalf",
"params": {
"PerHostPortion": "0.5",
"PoolSizeRatio": "0.75"
},
"enable_features": [
"QuotaExpandPoolSize"
]
},
{
"name": "Enabled_Pool_Full_Origin_OneHalf",
"params": {
"PerHostPortion": "0.5",
"PoolSizeRatio": "1.0"
},
"enable_features": [
"QuotaExpandPoolSize"
]
},
{
"name": "Enabled_Pool_TwoThirds_Origin_TwoThirds",
"params": {
"PerHostPortion": "0.6666666666666666",
"PoolSizeRatio": "0.6666666666666666"
},
"enable_features": [
"QuotaExpandPoolSize"
]
},
{
"name": "Enabled_Pool_ThreeQuarters_Origin_TwoThirds",
"params": {
"PerHostPortion": "0.6666666666666666",
"PoolSizeRatio": "0.75"
},
"enable_features": [
"QuotaExpandPoolSize"
]
},
{
"name": "Enabled_Pool_Full_Origin_TwoThirds",
"params": {
"PerHostPortion": "0.6666666666666666",
"PoolSizeRatio": "1.0"
},
"enable_features": [
"QuotaExpandPoolSize"
]
}
]
}
],
"ReaderModeUI": [
{
"platforms": [
Expand Down

0 comments on commit 7a79f06

Please sign in to comment.