Commit 6c9f35c4 authored by Bartek Nowierski's avatar Bartek Nowierski Committed by Commit Bot

[PartitionAlloc] Disable zeroing on Free() temporarily

We're currently evaluating performance of PartitionAlloc-Everywhere
(PA-E). Any regressions from zeroing would be inedvartantly attributed
to PA-E, as it hugely increases number of memory allocations going
through this path.

The best course of action would be to postone zeroing until PA-E is
fully evaluated and enabled in trunk. Then we should re-enable zeroing
and properly re-evaluate it in the new world.

Change-Id: I06ee7c63d10b2a14c76a7bd51faab7b616621c88
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521881Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarChris Palmer <palmer@chromium.org>
Commit-Queue: Bartek Nowierski <bartekn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825702}
parent c61d2d64
......@@ -50,6 +50,12 @@
#include "base/optional.h"
#include "build/build_config.h"
// If set to 1, enables zeroing memory on Free() with roughly 1% probability.
// This applies only to normal buckets, as direct-map allocations are always
// decommitted.
// TODO(bartekn): Re-enable once PartitionAlloc-Everywhere evaluation is done.
#define ZERO_RANDOMLY_ON_FREE 0
// We use this to make MEMORY_TOOL_REPLACES_ALLOCATOR behave the same for max
// size as other alloc code.
#define CHECK_MAX_SIZE_OR_RETURN_NULLPTR(size, flags) \
......@@ -570,7 +576,10 @@ ALWAYS_INLINE void PartitionRoot<thread_safe>::FreeNoHooksImmediate(
// Note: tag, ref-count and cookie can be 0-sized.
//
// For more context, see the other "Layout inside the slot" comment below.
#if ENABLE_REF_COUNT_FOR_BACKUP_REF_PTR || DCHECK_IS_ON() || \
ZERO_RANDOMLY_ON_FREE
const size_t utilized_slot_size = slot_span->GetUtilizedSlotSize();
#endif
if (allow_extras) {
#if ENABLE_REF_COUNT_FOR_BACKUP_REF_PTR || DCHECK_IS_ON()
size_t usable_size = internal::PartitionSizeAdjustSubtract(
......@@ -623,7 +632,7 @@ ALWAYS_INLINE void PartitionRoot<thread_safe>::FreeNoHooksImmediate(
#if DCHECK_IS_ON()
memset(ptr, kFreedByte, utilized_slot_size);
#else
#elif ZERO_RANDOMLY_ON_FREE
// `memset` only once in a while: we're trading off safety for time
// efficiency.
if (UNLIKELY(internal::RandomPeriod()) &&
......
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