Commit d7e35ffe authored by Eugene But's avatar Eugene But Committed by Commit Bot

[ios] Allow Finch-controlled reduction of persistent session size

This CL allows to change max number of stored and restored navigation
items via Finch within [40, 75] range. This experiment will allow to
understand if reducing stored session size can reduce out of memory
crashes.

Bug: 1115279
Change-Id: I2a4c40f6949631df4eaa503f21b909cd0c3994ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2493120Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Auto-Submit: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820334}
parent 8e9fed14
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
namespace web { namespace web {
namespace features { namespace features {
// Reduces the size of the session to persist when enabled. Specific size is
// obtained from "session-size" Finch parameter.
extern const base::Feature kReduceSessionSize;
// Used to crash the browser if unexpected URL change is detected. // Used to crash the browser if unexpected URL change is detected.
// https://crbug.com/841105. // https://crbug.com/841105.
extern const base::Feature kCrashOnUnexpectedURLChange; extern const base::Feature kCrashOnUnexpectedURLChange;
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
namespace web { namespace web {
namespace features { namespace features {
const base::Feature kReduceSessionSize{"ReduceSessionSize",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kCrashOnUnexpectedURLChange{ const base::Feature kCrashOnUnexpectedURLChange{
"CrashOnUnexpectedURLChange", base::FEATURE_ENABLED_BY_DEFAULT}; "CrashOnUnexpectedURLChange", base::FEATURE_ENABLED_BY_DEFAULT};
......
...@@ -40,9 +40,22 @@ int GetSafeItemRange(int last_committed_item_index, ...@@ -40,9 +40,22 @@ int GetSafeItemRange(int last_committed_item_index,
int item_count, int item_count,
int* offset, int* offset,
int* size) { int* size) {
*size = std::min(kMaxSessionSize, item_count); int max_session_size = kMaxSessionSize;
*offset = std::min(last_committed_item_index - kMaxSessionSize / 2, if (base::FeatureList::IsEnabled(features::kReduceSessionSize)) {
item_count - kMaxSessionSize); if (@available(iOS 14.0, *)) {
// IOS.MetricKit.ForegroundExitData is supported starting from iOS 14, and
// it's the only good metric to track effect of the session size on OOM
// crashes.
max_session_size = base::GetFieldTrialParamByFeatureAsInt(
features::kReduceSessionSize, "session-size", kMaxSessionSize);
max_session_size = MIN(max_session_size, kMaxSessionSize);
max_session_size = MAX(max_session_size, 40);
}
}
*size = std::min(max_session_size, item_count);
*offset = std::min(last_committed_item_index - max_session_size / 2,
item_count - max_session_size);
*offset = std::max(*offset, 0); *offset = std::max(*offset, 0);
return last_committed_item_index - *offset; return last_committed_item_index - *offset;
} }
......
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