blob: 5918df5da877ac92490ef97cf587bcc54552663f [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2020 The Chromium Authors
Takashi Sakamoto0044f2f2020-06-04 04:19:162// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Takashi Sakamoto1b5312d2021-10-18 08:53:465#include "base/allocator/partition_alloc_features.h"
Takashi Sakamoto0044f2f2020-06-04 04:19:166
Mingyu Leif0cffc92023-10-18 18:20:077#include "base/allocator/miracle_parameter.h"
Arthur Sonzogni0bcc0232023-10-03 08:48:328#include "base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time.h"
9#include "base/allocator/partition_allocator/src/partition_alloc/partition_alloc_buildflags.h"
10#include "base/allocator/partition_allocator/src/partition_alloc/partition_root.h"
11#include "base/allocator/partition_allocator/src/partition_alloc/thread_cache.h"
David Sanders6e709942022-04-05 06:49:2612#include "base/base_export.h"
Takashi Sakamoto0044f2f2020-06-04 04:19:1613#include "base/feature_list.h"
Takashi Sakamoto2e824dc2023-07-14 01:52:3514#include "base/features.h"
Mingyu Leiaf2e0d92023-09-07 06:35:0815#include "base/metrics/field_trial_params.h"
16#include "base/time/time.h"
Benoit Lize2e4a8f62022-01-12 13:35:2117#include "build/build_config.h"
Keishi Hattori50365c22023-04-27 08:09:2318#include "build/chromecast_buildflags.h"
19#include "build/chromeos_buildflags.h"
Takashi Sakamoto0044f2f2020-06-04 04:19:1620
21namespace base {
Takashi Sakamoto0c9274d2020-10-08 04:17:3722namespace features {
Takashi Sakamoto0044f2f2020-06-04 04:19:1623
Paul Semelb0ce4842022-09-28 08:09:5324BASE_FEATURE(kPartitionAllocUnretainedDanglingPtr,
25 "PartitionAllocUnretainedDanglingPtr",
Paul Semel1c64c332023-06-13 12:52:3926 FEATURE_ENABLED_BY_DEFAULT);
Paul Semelb0ce4842022-09-28 08:09:5327
28constexpr FeatureParam<UnretainedDanglingPtrMode>::Option
29 kUnretainedDanglingPtrModeOption[] = {
30 {UnretainedDanglingPtrMode::kCrash, "crash"},
31 {UnretainedDanglingPtrMode::kDumpWithoutCrashing,
32 "dump_without_crashing"},
33};
34const base::FeatureParam<UnretainedDanglingPtrMode>
35 kUnretainedDanglingPtrModeParam = {
36 &kPartitionAllocUnretainedDanglingPtr,
37 "mode",
38 UnretainedDanglingPtrMode::kDumpWithoutCrashing,
39 &kUnretainedDanglingPtrModeOption,
40};
41
Daniel Cheng0fff5c232022-09-21 17:43:3442BASE_FEATURE(kPartitionAllocDanglingPtr,
43 "PartitionAllocDanglingPtr",
Paul Semel14afb202023-06-29 14:52:2944#if BUILDFLAG(ENABLE_DANGLING_RAW_PTR_FEATURE_FLAG) || \
45 (BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS) && BUILDFLAG(IS_LINUX) && \
Paul Semela55ad502023-07-28 13:47:4946 !defined(OFFICIAL_BUILD) && (!defined(NDEBUG) || DCHECK_IS_ON()))
Arthur Sonzognif6e556d02023-02-21 10:09:0547 FEATURE_ENABLED_BY_DEFAULT
48#else
49 FEATURE_DISABLED_BY_DEFAULT
50#endif
51);
52
Arthur Sonzognibe6f0132022-07-06 13:54:1253constexpr FeatureParam<DanglingPtrMode>::Option kDanglingPtrModeOption[] = {
54 {DanglingPtrMode::kCrash, "crash"},
Pârise90af2c2023-01-30 14:22:4155 {DanglingPtrMode::kLogOnly, "log_only"},
Arthur Sonzognibe6f0132022-07-06 13:54:1256};
57const base::FeatureParam<DanglingPtrMode> kDanglingPtrModeParam{
58 &kPartitionAllocDanglingPtr,
59 "mode",
60 DanglingPtrMode::kCrash,
61 &kDanglingPtrModeOption,
62};
Pârise90af2c2023-01-30 14:22:4163constexpr FeatureParam<DanglingPtrType>::Option kDanglingPtrTypeOption[] = {
64 {DanglingPtrType::kAll, "all"},
65 {DanglingPtrType::kCrossTask, "cross_task"},
66};
67const base::FeatureParam<DanglingPtrType> kDanglingPtrTypeParam{
68 &kPartitionAllocDanglingPtr,
69 "type",
70 DanglingPtrType::kAll,
71 &kDanglingPtrTypeOption,
72};
Arthur Sonzognibe6f0132022-07-06 13:54:1273
Bartek Nowierskibc01b7112023-02-01 14:11:4274#if BUILDFLAG(USE_STARSCAN)
Anton Bikineev9d8b21b2020-10-09 08:11:5875// If enabled, PCScan is turned on by default for all partitions that don't
76// disable it explicitly.
Daniel Cheng0fff5c232022-09-21 17:43:3477BASE_FEATURE(kPartitionAllocPCScan,
78 "PartitionAllocPCScan",
79 FEATURE_DISABLED_BY_DEFAULT);
Bartek Nowierskibc01b7112023-02-01 14:11:4280#endif // BUILDFLAG(USE_STARSCAN)
Anton Bikineev9d8b21b2020-10-09 08:11:5881
Anton Bikineevdb908de2020-12-08 14:48:1382#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
83// If enabled, PCScan is turned on only for the browser's malloc partition.
Daniel Cheng0fff5c232022-09-21 17:43:3484BASE_FEATURE(kPartitionAllocPCScanBrowserOnly,
85 "PartitionAllocPCScanBrowserOnly",
86 FEATURE_DISABLED_BY_DEFAULT);
Benoit Lize6ae00272021-02-25 15:56:5387
Anton Bikineevd2509332021-09-16 17:14:5788// If enabled, PCScan is turned on only for the renderer's malloc partition.
Daniel Cheng0fff5c232022-09-21 17:43:3489BASE_FEATURE(kPartitionAllocPCScanRendererOnly,
90 "PartitionAllocPCScanRendererOnly",
91 FEATURE_DISABLED_BY_DEFAULT);
Anton Bikineevd2509332021-09-16 17:14:5792
Benoit Lize006cfcb2021-03-29 16:18:5293// Use a larger maximum thread cache cacheable bucket size.
Daniel Cheng0fff5c232022-09-21 17:43:3494BASE_FEATURE(kPartitionAllocLargeThreadCacheSize,
95 "PartitionAllocLargeThreadCacheSize",
Bartek Nowierski4152aa62023-09-11 14:48:4096 FEATURE_ENABLED_BY_DEFAULT);
Benoit Lize006cfcb2021-03-29 16:18:5297
Mingyu Leif0cffc92023-10-18 18:20:0798MIRACLE_PARAMETER_FOR_INT(
99 GetPartitionAllocLargeThreadCacheSizeValue,
100 kPartitionAllocLargeThreadCacheSize,
Mingyu Leid313bb72023-09-06 02:23:28101 "PartitionAllocLargeThreadCacheSizeValue",
Mingyu Leif0cffc92023-10-18 18:20:07102 ::partition_alloc::ThreadCacheLimits::kLargeSizeThreshold)
Mingyu Leid313bb72023-09-06 02:23:28103
Mingyu Leif0cffc92023-10-18 18:20:07104MIRACLE_PARAMETER_FOR_INT(
105 GetPartitionAllocLargeThreadCacheSizeValueForLowRAMAndroid,
106 kPartitionAllocLargeThreadCacheSize,
107 "PartitionAllocLargeThreadCacheSizeValueForLowRAMAndroid",
108 ::partition_alloc::ThreadCacheLimits::kDefaultSizeThreshold)
Mingyu Leid313bb72023-09-06 02:23:28109
Daniel Cheng0fff5c232022-09-21 17:43:34110BASE_FEATURE(kPartitionAllocLargeEmptySlotSpanRing,
111 "PartitionAllocLargeEmptySlotSpanRing",
112 FEATURE_DISABLED_BY_DEFAULT);
miktca35b70b2023-11-01 12:55:56113
114BASE_FEATURE(kPartitionAllocSchedulerLoopQuarantine,
115 "PartitionAllocSchedulerLoopQuarantine",
116 FEATURE_DISABLED_BY_DEFAULT);
117// Scheduler Loop Quarantine's capacity in bytes.
118const base::FeatureParam<int> kPartitionAllocSchedulerLoopQuarantineCapacity{
119 &kPartitionAllocSchedulerLoopQuarantine,
120 "PartitionAllocSchedulerLoopQuarantineCapacity", 0};
Sergei Glazunov7afc89b92022-05-31 19:31:29121#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
Benoit Lizef13d7932022-01-07 10:29:32122
Daniel Cheng0fff5c232022-09-21 17:43:34123BASE_FEATURE(kPartitionAllocBackupRefPtr,
124 "PartitionAllocBackupRefPtr",
Keishi Hattori50365c22023-04-27 08:09:23125#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || \
Keishi Hattori663c81f2023-08-11 06:40:17126 BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) || \
Keishi Hattori50365c22023-04-27 08:09:23127 (BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CASTOS)) || \
Bartek Nowierskieed11392023-08-04 10:32:04128 BUILDFLAG(ENABLE_BACKUP_REF_PTR_FEATURE_FLAG)
Daniel Cheng0fff5c232022-09-21 17:43:34129 FEATURE_ENABLED_BY_DEFAULT
Keishi Hattoriebb719d2022-05-13 09:40:30130#else
Daniel Cheng0fff5c232022-09-21 17:43:34131 FEATURE_DISABLED_BY_DEFAULT
Keishi Hattoriebb719d2022-05-13 09:40:30132#endif
Daniel Cheng0fff5c232022-09-21 17:43:34133);
Keishi Hattoriaf499ac2021-09-22 23:45:04134
Bartek Nowierskidd715522023-05-04 11:13:44135BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocBackupRefPtrForAsh);
136BASE_FEATURE(kPartitionAllocBackupRefPtrForAsh,
137 "PartitionAllocBackupRefPtrForAsh",
Bartek Nowierski7ccccb52023-08-30 20:37:57138 FEATURE_ENABLED_BY_DEFAULT);
Bartek Nowierskidd715522023-05-04 11:13:44139
Keishi Hattoriaf499ac2021-09-22 23:45:04140constexpr FeatureParam<BackupRefPtrEnabledProcesses>::Option
141 kBackupRefPtrEnabledProcessesOptions[] = {
142 {BackupRefPtrEnabledProcesses::kBrowserOnly, "browser-only"},
143 {BackupRefPtrEnabledProcesses::kBrowserAndRenderer,
Bartek Nowierskie9ad8a7d2021-11-04 08:37:39144 "browser-and-renderer"},
Bartek Nowierski76680472021-12-09 17:58:25145 {BackupRefPtrEnabledProcesses::kNonRenderer, "non-renderer"},
Bartek Nowierskie9ad8a7d2021-11-04 08:37:39146 {BackupRefPtrEnabledProcesses::kAllProcesses, "all-processes"}};
Keishi Hattoriaf499ac2021-09-22 23:45:04147
148const base::FeatureParam<BackupRefPtrEnabledProcesses>
Bartek Nowierski0100c0012023-06-21 06:37:51149 kBackupRefPtrEnabledProcessesParam{
150 &kPartitionAllocBackupRefPtr, "enabled-processes",
151 BackupRefPtrEnabledProcesses::kNonRenderer,
152 &kBackupRefPtrEnabledProcessesOptions};
Keishi Hattoriaf499ac2021-09-22 23:45:04153
Bartek Nowierskif7264202023-05-17 00:23:52154constexpr FeatureParam<BackupRefPtrRefCountSize>::Option
155 kBackupRefPtrRefCountSizeOptions[] = {
156 {BackupRefPtrRefCountSize::kNatural, "natural"},
157 {BackupRefPtrRefCountSize::k4B, "4B"},
158 {BackupRefPtrRefCountSize::k8B, "8B"},
159 {BackupRefPtrRefCountSize::k16B, "16B"}};
160
161const base::FeatureParam<BackupRefPtrRefCountSize>
162 kBackupRefPtrRefCountSizeParam{
163 &kPartitionAllocBackupRefPtr, "ref-count-size",
164 BackupRefPtrRefCountSize::kNatural, &kBackupRefPtrRefCountSizeOptions};
165
Bartek Nowierskiccb1929b2023-07-21 02:35:55166// Map -with-memory-reclaimer modes onto their counterpars without the suffix.
167// They are the same, as memory reclaimer is now controlled independently.
168// However, we need to keep both option strings, as there is a long tail of
169// clients that may have an old field trial config, which used these modes.
170//
171// DO NOT USE -with-memory-reclaimer modes in new configs!
Bartek Nowierskida7d8f1c2021-12-08 19:30:59172constexpr FeatureParam<BackupRefPtrMode>::Option kBackupRefPtrModeOptions[] = {
Bartek Nowierskiea35aa522021-12-10 07:08:20173 {BackupRefPtrMode::kDisabled, "disabled"},
Bartek Nowierskida7d8f1c2021-12-08 19:30:59174 {BackupRefPtrMode::kEnabled, "enabled"},
Bartek Nowierskiccb1929b2023-07-21 02:35:55175 {BackupRefPtrMode::kEnabled, "enabled-with-memory-reclaimer"},
Bartek Nowierskida7d8f1c2021-12-08 19:30:59176 {BackupRefPtrMode::kDisabledButSplitPartitions2Way,
177 "disabled-but-2-way-split"},
Bartek Nowierskiccb1929b2023-07-21 02:35:55178 {BackupRefPtrMode::kDisabledButSplitPartitions2Way,
179 "disabled-but-2-way-split-with-memory-reclaimer"},
Bartek Nowierskida7d8f1c2021-12-08 19:30:59180 {BackupRefPtrMode::kDisabledButSplitPartitions3Way,
181 "disabled-but-3-way-split"},
182};
Bartek Nowierskie9ad8a7d2021-11-04 08:37:39183
Bartek Nowierskida7d8f1c2021-12-08 19:30:59184const base::FeatureParam<BackupRefPtrMode> kBackupRefPtrModeParam{
Bartek Nowierski1992f4532023-07-11 15:06:35185 &kPartitionAllocBackupRefPtr, "brp-mode", BackupRefPtrMode::kEnabled,
186 &kBackupRefPtrModeOptions};
Bartek Nowierskie9ad8a7d2021-11-04 08:37:39187
Keishi Hattori5f94b5e02023-05-23 15:01:57188BASE_FEATURE(kPartitionAllocMemoryTagging,
189 "PartitionAllocMemoryTagging",
190 FEATURE_DISABLED_BY_DEFAULT);
191
192constexpr FeatureParam<MemtagMode>::Option kMemtagModeOptions[] = {
193 {MemtagMode::kSync, "sync"},
194 {MemtagMode::kAsync, "async"}};
195
196const base::FeatureParam<MemtagMode> kMemtagModeParam{
197 &kPartitionAllocMemoryTagging, "memtag-mode", MemtagMode::kAsync,
198 &kMemtagModeOptions};
199
200constexpr FeatureParam<MemoryTaggingEnabledProcesses>::Option
201 kMemoryTaggingEnabledProcessesOptions[] = {
202 {MemoryTaggingEnabledProcesses::kBrowserOnly, "browser-only"},
203 {MemoryTaggingEnabledProcesses::kNonRenderer, "non-renderer"},
204 {MemoryTaggingEnabledProcesses::kAllProcesses, "all-processes"}};
205
206const base::FeatureParam<MemoryTaggingEnabledProcesses>
207 kMemoryTaggingEnabledProcessesParam{
208 &kPartitionAllocMemoryTagging, "enabled-processes",
209 MemoryTaggingEnabledProcesses::kBrowserOnly,
210 &kMemoryTaggingEnabledProcessesOptions};
211
Keishi Hattori4dddbef22023-06-01 09:31:56212BASE_FEATURE(kKillPartitionAllocMemoryTagging,
213 "KillPartitionAllocMemoryTagging",
214 FEATURE_DISABLED_BY_DEFAULT);
215
Keishi Hattori806e3d8e2023-09-06 05:55:52216BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPermissiveMte);
217BASE_FEATURE(kPartitionAllocPermissiveMte,
218 "PartitionAllocPermissiveMte",
219 FEATURE_ENABLED_BY_DEFAULT);
220
Sergei Glazunov7afc89b92022-05-31 19:31:29221const base::FeatureParam<bool> kBackupRefPtrAsanEnableDereferenceCheckParam{
222 &kPartitionAllocBackupRefPtr, "asan-enable-dereference-check", true};
223const base::FeatureParam<bool> kBackupRefPtrAsanEnableExtractionCheckParam{
224 &kPartitionAllocBackupRefPtr, "asan-enable-extraction-check",
225 false}; // Not much noise at the moment to enable by default.
226const base::FeatureParam<bool> kBackupRefPtrAsanEnableInstantiationCheckParam{
227 &kPartitionAllocBackupRefPtr, "asan-enable-instantiation-check", true};
Anton Bikineevdb908de2020-12-08 14:48:13228
Thiabaud Engelbrecht179001b2023-05-30 15:46:42229// If enabled, switches the bucket distribution to a denser one.
Thiabaud Engelbrecht7cd1e4a2023-04-20 14:39:20230//
231// We enable this by default everywhere except for 32-bit Android, since we saw
232// regressions there.
Thiabaud Engelbrecht179001b2023-05-30 15:46:42233BASE_FEATURE(kPartitionAllocUseDenserDistribution,
234 "PartitionAllocUseDenserDistribution",
Thiabaud Engelbrecht7cd1e4a2023-04-20 14:39:20235#if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS)
236 FEATURE_DISABLED_BY_DEFAULT
237#else
238 FEATURE_ENABLED_BY_DEFAULT
239#endif // BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS)
240);
Thiabaud Engelbrecht179001b2023-05-30 15:46:42241const base::FeatureParam<BucketDistributionMode>::Option
242 kPartitionAllocBucketDistributionOption[] = {
243 {BucketDistributionMode::kDefault, "default"},
244 {BucketDistributionMode::kDenser, "denser"},
Thiabaud Engelbrecht05f8b8112022-09-16 02:18:29245};
Thiabaud Engelbrecht179001b2023-05-30 15:46:42246const base::FeatureParam<BucketDistributionMode>
247 kPartitionAllocBucketDistributionParam {
248 &kPartitionAllocUseDenserDistribution, "mode",
249#if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS)
250 BucketDistributionMode::kDefault,
251#else
252 BucketDistributionMode::kDenser,
253#endif // BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS)
254 &kPartitionAllocBucketDistributionOption
255};
Thiabaud Engelbrecht1efe4372022-02-16 19:33:09256
Bartek Nowierski1992f4532023-07-11 15:06:35257BASE_FEATURE(kPartitionAllocMemoryReclaimer,
258 "PartitionAllocMemoryReclaimer",
259 FEATURE_ENABLED_BY_DEFAULT);
Yuki Shiinob127d75b2023-08-08 09:52:16260const base::FeatureParam<TimeDelta> kPartitionAllocMemoryReclaimerInterval = {
261 &kPartitionAllocMemoryReclaimer, "interval",
262 TimeDelta(), // Defaults to zero.
263};
Bartek Nowierski1992f4532023-07-11 15:06:35264
Arthur Sonzognia570236352022-12-19 13:18:54265// Configures whether we set a lower limit for renderers that do not have a main
266// frame, similar to the limit that is already done for backgrounded renderers.
267BASE_FEATURE(kLowerPAMemoryLimitForNonMainRenderers,
268 "LowerPAMemoryLimitForNonMainRenderers",
269 FEATURE_DISABLED_BY_DEFAULT);
270
Michael Lippautzd34f7b2c2021-04-21 08:32:26271// If enabled, switches PCScan scheduling to a mutator-aware scheduler. Does not
272// affect whether PCScan is enabled itself.
Daniel Cheng0fff5c232022-09-21 17:43:34273BASE_FEATURE(kPartitionAllocPCScanMUAwareScheduler,
274 "PartitionAllocPCScanMUAwareScheduler",
275 FEATURE_ENABLED_BY_DEFAULT);
Michael Lippautzd34f7b2c2021-04-21 08:32:26276
Hannes Payera33df7f2021-06-22 18:44:14277// If enabled, PCScan frees unconditionally all quarantined objects.
278// This is a performance testing feature.
Daniel Cheng0fff5c232022-09-21 17:43:34279BASE_FEATURE(kPartitionAllocPCScanImmediateFreeing,
280 "PartitionAllocPCScanImmediateFreeing",
281 FEATURE_DISABLED_BY_DEFAULT);
Hannes Payera33df7f2021-06-22 18:44:14282
Anton Bikineev7f11c212021-08-24 12:03:09283// If enabled, PCScan clears eagerly (synchronously) on free().
Daniel Cheng0fff5c232022-09-21 17:43:34284BASE_FEATURE(kPartitionAllocPCScanEagerClearing,
285 "PartitionAllocPCScanEagerClearing",
286 FEATURE_DISABLED_BY_DEFAULT);
Anton Bikineev7f11c212021-08-24 12:03:09287
Anton Bikineevea8859b2021-04-29 19:17:22288// In addition to heap, scan also the stack of the current mutator.
Daniel Cheng0fff5c232022-09-21 17:43:34289BASE_FEATURE(kPartitionAllocPCScanStackScanning,
290 "PartitionAllocPCScanStackScanning",
Bartek Nowierski92974a92023-02-02 08:12:30291#if BUILDFLAG(PCSCAN_STACK_SUPPORTED)
Daniel Cheng0fff5c232022-09-21 17:43:34292 FEATURE_ENABLED_BY_DEFAULT
Anton Bikineevea8859b2021-04-29 19:17:22293#else
Daniel Cheng0fff5c232022-09-21 17:43:34294 FEATURE_DISABLED_BY_DEFAULT
Bartek Nowierski92974a92023-02-02 08:12:30295#endif // BUILDFLAG(PCSCAN_STACK_SUPPORTED)
Daniel Cheng0fff5c232022-09-21 17:43:34296);
Anton Bikineevea8859b2021-04-29 19:17:22297
Daniel Cheng0fff5c232022-09-21 17:43:34298BASE_FEATURE(kPartitionAllocDCScan,
299 "PartitionAllocDCScan",
300 FEATURE_DISABLED_BY_DEFAULT);
Anton Bikineev6b5ab952021-05-19 23:57:57301
Bartek Nowierskiafd88212023-08-23 15:25:24302// Whether to straighten free lists for larger slot spans in PurgeMemory() ->
303// ... -> PartitionPurgeSlotSpan().
304BASE_FEATURE(kPartitionAllocStraightenLargerSlotSpanFreeLists,
305 "PartitionAllocStraightenLargerSlotSpanFreeLists",
306 FEATURE_ENABLED_BY_DEFAULT);
Bartek Nowierski50750532023-08-25 05:26:17307const base::FeatureParam<
308 partition_alloc::StraightenLargerSlotSpanFreeListsMode>::Option
309 kPartitionAllocStraightenLargerSlotSpanFreeListsModeOption[] = {
310 {partition_alloc::StraightenLargerSlotSpanFreeListsMode::
311 kOnlyWhenUnprovisioning,
312 "only-when-unprovisioning"},
313 {partition_alloc::StraightenLargerSlotSpanFreeListsMode::kAlways,
314 "always"},
315};
316const base::FeatureParam<partition_alloc::StraightenLargerSlotSpanFreeListsMode>
317 kPartitionAllocStraightenLargerSlotSpanFreeListsMode = {
318 &kPartitionAllocStraightenLargerSlotSpanFreeLists,
319 "mode",
320 partition_alloc::StraightenLargerSlotSpanFreeListsMode::
321 kOnlyWhenUnprovisioning,
322 &kPartitionAllocStraightenLargerSlotSpanFreeListsModeOption,
323};
Bartek Nowierskiafd88212023-08-23 15:25:24324
Bartek Nowierski3506afbc2023-08-18 03:58:38325// Whether to sort free lists for smaller slot spans in PurgeMemory().
Bartek Nowierski3506afbc2023-08-18 03:58:38326BASE_FEATURE(kPartitionAllocSortSmallerSlotSpanFreeLists,
327 "PartitionAllocSortSmallerSlotSpanFreeLists",
328 FEATURE_ENABLED_BY_DEFAULT);
329
Benoit Lizec9ec61492022-05-20 10:51:25330// Whether to sort the active slot spans in PurgeMemory().
Daniel Cheng0fff5c232022-09-21 17:43:34331BASE_FEATURE(kPartitionAllocSortActiveSlotSpans,
332 "PartitionAllocSortActiveSlotSpans",
333 FEATURE_DISABLED_BY_DEFAULT);
Benoit Lizec9ec61492022-05-20 10:51:25334
Benoit Lize7ebe3d42022-11-24 21:12:00335#if BUILDFLAG(IS_WIN)
336// Whether to retry allocations when commit fails.
337BASE_FEATURE(kPageAllocatorRetryOnCommitFailure,
338 "PageAllocatorRetryOnCommitFailure",
339 FEATURE_DISABLED_BY_DEFAULT);
340#endif
341
Erik Chen6968d882023-10-17 23:14:42342#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_CHROMEOS)
Takashi Sakamoto2e824dc2023-07-14 01:52:35343// A parameter to exclude or not exclude PartitionAllocSupport from
344// PartialLowModeOnMidRangeDevices. This is used to see how it affects
345// renderer performances, e.g. blink_perf.parser benchmark.
346// The feature: kPartialLowEndModeOnMidRangeDevices is defined in
347// //base/features.cc. Since the following feature param is related to
348// PartitionAlloc, define the param here.
349const FeatureParam<bool> kPartialLowEndModeExcludePartitionAllocSupport{
350 &kPartialLowEndModeOnMidRangeDevices, "exclude-partition-alloc-support",
351 false};
352#endif
353
Mingyu Lei247628542023-09-04 06:40:21354BASE_FEATURE(kEnableConfigurableThreadCacheMultiplier,
355 "EnableConfigurableThreadCacheMultiplier",
356 base::FEATURE_DISABLED_BY_DEFAULT);
357
Mingyu Lei21e0a642023-10-18 18:29:02358MIRACLE_PARAMETER_FOR_DOUBLE(GetThreadCacheMultiplier,
359 kEnableConfigurableThreadCacheMultiplier,
360 "ThreadCacheMultiplier",
361 2.)
Mingyu Lei247628542023-09-04 06:40:21362
Mingyu Lei21e0a642023-10-18 18:29:02363MIRACLE_PARAMETER_FOR_DOUBLE(GetThreadCacheMultiplierForAndroid,
364 kEnableConfigurableThreadCacheMultiplier,
365 "ThreadCacheMultiplierForAndroid",
366 1.)
Mingyu Lei247628542023-09-04 06:40:21367
Mingyu Leiaf2e0d92023-09-07 06:35:08368constexpr partition_alloc::internal::base::TimeDelta ToPartitionAllocTimeDelta(
369 base::TimeDelta time_delta) {
370 return partition_alloc::internal::base::Microseconds(
371 time_delta.InMicroseconds());
372}
373
374constexpr base::TimeDelta FromPartitionAllocTimeDelta(
375 partition_alloc::internal::base::TimeDelta time_delta) {
376 return base::Microseconds(time_delta.InMicroseconds());
377}
378
379BASE_FEATURE(kEnableConfigurableThreadCachePurgeInterval,
380 "EnableConfigurableThreadCachePurgeInterval",
381 base::FEATURE_DISABLED_BY_DEFAULT);
382
Mingyu Leidd8c3d52023-10-19 05:28:41383MIRACLE_PARAMETER_FOR_TIME_DELTA(
384 GetThreadCacheMinPurgeIntervalValue,
385 kEnableConfigurableThreadCachePurgeInterval,
386 "ThreadCacheMinPurgeInterval",
387 FromPartitionAllocTimeDelta(partition_alloc::kMinPurgeInterval))
Mingyu Leiaf2e0d92023-09-07 06:35:08388
Mingyu Leidd8c3d52023-10-19 05:28:41389MIRACLE_PARAMETER_FOR_TIME_DELTA(
390 GetThreadCacheMaxPurgeIntervalValue,
391 kEnableConfigurableThreadCachePurgeInterval,
392 "ThreadCacheMaxPurgeInterval",
393 FromPartitionAllocTimeDelta(partition_alloc::kMaxPurgeInterval))
Mingyu Leiaf2e0d92023-09-07 06:35:08394
Mingyu Leidd8c3d52023-10-19 05:28:41395MIRACLE_PARAMETER_FOR_TIME_DELTA(
396 GetThreadCacheDefaultPurgeIntervalValue,
397 kEnableConfigurableThreadCachePurgeInterval,
Mingyu Leiaf2e0d92023-09-07 06:35:08398 "ThreadCacheDefaultPurgeInterval",
Mingyu Leidd8c3d52023-10-19 05:28:41399 FromPartitionAllocTimeDelta(partition_alloc::kDefaultPurgeInterval))
Mingyu Leiaf2e0d92023-09-07 06:35:08400
401const partition_alloc::internal::base::TimeDelta
402GetThreadCacheMinPurgeInterval() {
Mingyu Leidd8c3d52023-10-19 05:28:41403 return ToPartitionAllocTimeDelta(GetThreadCacheMinPurgeIntervalValue());
Mingyu Leiaf2e0d92023-09-07 06:35:08404}
405
406const partition_alloc::internal::base::TimeDelta
407GetThreadCacheMaxPurgeInterval() {
Mingyu Leidd8c3d52023-10-19 05:28:41408 return ToPartitionAllocTimeDelta(GetThreadCacheMaxPurgeIntervalValue());
Mingyu Leiaf2e0d92023-09-07 06:35:08409}
410
411const partition_alloc::internal::base::TimeDelta
412GetThreadCacheDefaultPurgeInterval() {
Mingyu Leidd8c3d52023-10-19 05:28:41413 return ToPartitionAllocTimeDelta(GetThreadCacheDefaultPurgeIntervalValue());
Mingyu Leiaf2e0d92023-09-07 06:35:08414}
415
416BASE_FEATURE(kEnableConfigurableThreadCacheMinCachedMemoryForPurging,
417 "EnableConfigurableThreadCacheMinCachedMemoryForPurging",
418 base::FEATURE_DISABLED_BY_DEFAULT);
419
Mingyu Lei597be2d2023-10-19 05:31:04420MIRACLE_PARAMETER_FOR_INT(
421 GetThreadCacheMinCachedMemoryForPurgingBytes,
422 kEnableConfigurableThreadCacheMinCachedMemoryForPurging,
Mingyu Leiaf2e0d92023-09-07 06:35:08423 "ThreadCacheMinCachedMemoryForPurgingBytes",
Mingyu Lei597be2d2023-10-19 05:31:04424 partition_alloc::kMinCachedMemoryForPurgingBytes)
Mingyu Leiaf2e0d92023-09-07 06:35:08425
Kalvin Leee933f3a2023-10-22 07:34:44426// An apparent quarantine leak in the buffer partition unacceptably
427// bloats memory when MiraclePtr is enabled in the renderer process.
428// We believe we have found and patched the leak, but out of an
429// abundance of caution, we provide this toggle that allows us to
430// wholly disable MiraclePtr in the buffer partition, if necessary.
431//
432// TODO(crbug.com/1444624): this is unneeded once
433// MiraclePtr-for-Renderer launches.
434BASE_FEATURE(kPartitionAllocDisableBRPInBufferPartition,
435 "PartitionAllocDisableBRPInBufferPartition",
436 FEATURE_DISABLED_BY_DEFAULT);
437
Takashi Sakamoto0c9274d2020-10-08 04:17:37438} // namespace features
Takashi Sakamoto0044f2f2020-06-04 04:19:16439} // namespace base