Commit c327ca61 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Avoid address-space exhaustion on 32-bit test processes

When running base_perftests for x86 an out-of-memory failure is hit on
MemoryAllocationPerfTest.SingleBucket/3. This test was already disabled
on Android due to its excessive use of memory and this change disables
the test for all 32-bit processes.

With this change it is now possible to run base_perftests for x86.

Change-Id: If3cfbd8b754ae6f09f70e989ac1cab94e2a188be
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2288829Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786633}
parent 590d7284
...@@ -15,6 +15,12 @@ ...@@ -15,6 +15,12 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_result_reporter.h" #include "testing/perf/perf_result_reporter.h"
#if defined(OS_ANDROID) || defined(ARCH_CPU_32_BITS)
// Some tests allocate many GB of memory, which can cause issues on Android and
// address-space exhaustion for any 32-bit process.
#define MEMORY_CONSTRAINED
#endif
namespace base { namespace base {
namespace { namespace {
...@@ -119,7 +125,7 @@ class MemoryAllocationPerfNode { ...@@ -119,7 +125,7 @@ class MemoryAllocationPerfNode {
MemoryAllocationPerfNode* next_ = nullptr; MemoryAllocationPerfNode* next_ = nullptr;
}; };
#if !defined(OS_ANDROID) #if !defined(MEMORY_CONSTRAINED)
float SingleBucket(Allocator* allocator) { float SingleBucket(Allocator* allocator) {
auto* first = auto* first =
reinterpret_cast<MemoryAllocationPerfNode*>(allocator->Alloc(40)); reinterpret_cast<MemoryAllocationPerfNode*>(allocator->Alloc(40));
...@@ -142,7 +148,7 @@ float SingleBucket(Allocator* allocator) { ...@@ -142,7 +148,7 @@ float SingleBucket(Allocator* allocator) {
MemoryAllocationPerfNode::FreeAll(first, allocator); MemoryAllocationPerfNode::FreeAll(first, allocator);
return timer.LapsPerSecond(); return timer.LapsPerSecond();
} }
#endif // defined(OS_ANDROID) #endif // defined(MEMORY_CONSTRAINED)
float SingleBucketWithFree(Allocator* allocator) { float SingleBucketWithFree(Allocator* allocator) {
// Allocate an initial element to make sure the bucket stays set up. // Allocate an initial element to make sure the bucket stays set up.
...@@ -160,7 +166,7 @@ float SingleBucketWithFree(Allocator* allocator) { ...@@ -160,7 +166,7 @@ float SingleBucketWithFree(Allocator* allocator) {
return timer.LapsPerSecond(); return timer.LapsPerSecond();
} }
#if !defined(OS_ANDROID) #if !defined(MEMORY_CONSTRAINED)
float MultiBucket(Allocator* allocator) { float MultiBucket(Allocator* allocator) {
auto* first = auto* first =
reinterpret_cast<MemoryAllocationPerfNode*>(allocator->Alloc(40)); reinterpret_cast<MemoryAllocationPerfNode*>(allocator->Alloc(40));
...@@ -183,7 +189,7 @@ float MultiBucket(Allocator* allocator) { ...@@ -183,7 +189,7 @@ float MultiBucket(Allocator* allocator) {
return timer.LapsPerSecond() * kMultiBucketRounds; return timer.LapsPerSecond() * kMultiBucketRounds;
} }
#endif // defined(OS_ANDROID) #endif // defined(MEMORY_CONSTRAINED)
float MultiBucketWithFree(Allocator* allocator) { float MultiBucketWithFree(Allocator* allocator) {
std::vector<void*> elems; std::vector<void*> elems;
...@@ -263,13 +269,13 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -263,13 +269,13 @@ INSTANTIATE_TEST_SUITE_P(
// This test (and the other one below) allocates a large amount of memory, which // This test (and the other one below) allocates a large amount of memory, which
// can cause issues on Android. // can cause issues on Android.
#if !defined(OS_ANDROID) #if !defined(MEMORY_CONSTRAINED)
TEST_P(MemoryAllocationPerfTest, SingleBucket) { TEST_P(MemoryAllocationPerfTest, SingleBucket) {
auto params = GetParam(); auto params = GetParam();
RunTest(std::get<0>(params), std::get<1>(params), SingleBucket, RunTest(std::get<0>(params), std::get<1>(params), SingleBucket,
"SingleBucket"); "SingleBucket");
} }
#endif #endif // defined(MEMORY_CONSTRAINED)
TEST_P(MemoryAllocationPerfTest, SingleBucketWithFree) { TEST_P(MemoryAllocationPerfTest, SingleBucketWithFree) {
auto params = GetParam(); auto params = GetParam();
...@@ -277,12 +283,12 @@ TEST_P(MemoryAllocationPerfTest, SingleBucketWithFree) { ...@@ -277,12 +283,12 @@ TEST_P(MemoryAllocationPerfTest, SingleBucketWithFree) {
"SingleBucketWithFree"); "SingleBucketWithFree");
} }
#if !defined(OS_ANDROID) #if !defined(MEMORY_CONSTRAINED)
TEST_P(MemoryAllocationPerfTest, MultiBucket) { TEST_P(MemoryAllocationPerfTest, MultiBucket) {
auto params = GetParam(); auto params = GetParam();
RunTest(std::get<0>(params), std::get<1>(params), MultiBucket, "MultiBucket"); RunTest(std::get<0>(params), std::get<1>(params), MultiBucket, "MultiBucket");
} }
#endif #endif // defined(MEMORY_CONSTRAINED)
TEST_P(MemoryAllocationPerfTest, MultiBucketWithFree) { TEST_P(MemoryAllocationPerfTest, MultiBucketWithFree) {
auto params = GetParam(); auto params = GetParam();
......
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