From 6e89233b7427b0797a01b6b77bf3bb5dd5eaa601 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 25 May 2016 14:00:41 -0800 Subject: [PATCH] Make the gput_allocator_retry_test *Fail test cases more reliable by having each consumer thread pause for 1 msec between getting its memory and returning it. Logged failures for the NoRetryFail case suggest that on OS/X thread scheduling is such that without this delay it's possible not to experience a race condition failure within 10 seconds. Change: 123257296 --- .../core/common_runtime/gpu/gpu_allocator_retry_test.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tensorflow/core/common_runtime/gpu/gpu_allocator_retry_test.cc b/tensorflow/core/common_runtime/gpu/gpu_allocator_retry_test.cc index c03cb27df50..c911290f28b 100644 --- a/tensorflow/core/common_runtime/gpu/gpu_allocator_retry_test.cc +++ b/tensorflow/core/common_runtime/gpu/gpu_allocator_retry_test.cc @@ -81,6 +81,9 @@ class GPUAllocatorRetryTest : public ::testing::Test { return; } } + // Failures are more likely to occur if each consumer + // delays for a while before returning the memory. + Env::Default()->SleepForMicroseconds(500); ++consumer_count_[i]; for (int j = 0; j < cap_needed; ++j) { alloc_->DeallocateRaw(ptr); @@ -141,9 +144,10 @@ TEST_F(GPUAllocatorRetryTest, RetrySuccess) { EXPECT_GT(consumer_count_[2], 0); } -/* Disabled due to flakiness. b/24738751 // Verifies OutOfMemory failure when memory is slightly overcommitted -// and retry is not allowed. +// and retry is not allowed. Note that this test will fail, i.e. no +// memory alloc failure will be detected, if it is run in a context that +// does not permit real multi-threaded execution. TEST_F(GPUAllocatorRetryTest, NoRetryFail) { // Support up to 2 allocations simultaneously, waits up to 0 msec for // a chance to alloc. @@ -162,7 +166,6 @@ TEST_F(GPUAllocatorRetryTest, NoRetryFail) { EXPECT_TRUE(has_failed_); } } -*/ // Verifies OutOfMemory failure when retry is allowed but memory capacity // is too low even for retry.