This is an automated email from the ASF dual-hosted git repository.
adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new a5848a4 [test] deflake more for memory_gc-itest (2nd)
a5848a4 is described below
commit a5848a4c3c8c72a1ac823182e87cd1f6c31ddc15
Author: Yingchun Lai <[email protected]>
AuthorDate: Sat Oct 26 09:51:24 2019 +0800
[test] deflake more for memory_gc-itest (2nd)
Change-Id: Ia73569337caa2c59d0b23580d12763f016a8eaa9
Reviewed-on: http://gerrit.cloudera.org:8080/14553
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <[email protected]>
---
src/kudu/integration-tests/memory_gc-itest.cc | 39 ++++++++++++++++-----------
src/kudu/util/process_memory.cc | 7 ++++-
2 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/src/kudu/integration-tests/memory_gc-itest.cc
b/src/kudu/integration-tests/memory_gc-itest.cc
index 8851884..03119c3 100644
--- a/src/kudu/integration-tests/memory_gc-itest.cc
+++ b/src/kudu/integration-tests/memory_gc-itest.cc
@@ -29,6 +29,7 @@
#include "kudu/integration-tests/test_workload.h"
#include "kudu/mini-cluster/external_mini_cluster.h"
#include "kudu/util/metrics.h"
+#include "kudu/util/monotime.h"
#include "kudu/util/status.h"
#include "kudu/util/test_macros.h"
#include "kudu/util/test_util.h"
@@ -66,15 +67,18 @@ class MemoryGcITest : public ExternalMiniClusterITestBase {
TEST_F(MemoryGcITest, TestPeriodicGc) {
vector<string> ts_flags;
- // Set GC interval seconeds short enough, so the test case could compelte
sooner.
+ // Set GC interval seconds short enough, so the test case could complete
sooner.
ts_flags.emplace_back("--gc_tcmalloc_memory_interval_seconds=5");
+ // Disable tcmalloc memory GC by memory tracker, but periodical tcmalloc
memory
+ // GC is still enabled.
+
ts_flags.emplace_back("--disable_tcmalloc_gc_by_memory_tracker_for_testing=true");
ExternalMiniClusterOptions opts;
opts.extra_tserver_flags = std::move(ts_flags);
opts.num_tablet_servers = 3;
NO_FATALS(StartClusterWithOpts(opts));
- // Enable tcmalloc memory GC periodically for tserver-1, and disabled for
tserver-0 and tserver-2.
+ // Disable periodical tcmalloc memory GC for tserver-0 and tserver-2.
ASSERT_OK(cluster_->SetFlag(cluster_->tablet_server(0),
"gc_tcmalloc_memory_interval_seconds", "0"));
ASSERT_OK(cluster_->SetFlag(cluster_->tablet_server(1),
@@ -85,6 +89,7 @@ TEST_F(MemoryGcITest, TestPeriodicGc) {
// Write some data for scan later.
{
TestWorkload workload(cluster_.get());
+ workload.set_num_tablets(60);
workload.set_num_replicas(1);
workload.set_num_write_threads(4);
workload.set_write_batch_size(10);
@@ -92,7 +97,7 @@ TEST_F(MemoryGcITest, TestPeriodicGc) {
workload.Setup();
workload.Start();
ASSERT_EVENTUALLY([&]() {
- ASSERT_GE(workload.rows_inserted(), 100000);
+ ASSERT_GE(workload.rows_inserted(), 30000);
});
workload.StopAndJoin();
}
@@ -101,22 +106,26 @@ TEST_F(MemoryGcITest, TestPeriodicGc) {
{
TestWorkload workload(cluster_.get());
workload.set_num_write_threads(0);
- workload.set_num_read_threads(4);
+ workload.set_num_read_threads(8);
workload.Setup();
workload.Start();
- ASSERT_EVENTUALLY([&]() {
- NO_FATALS(
- double ratio;
- GetOverheadRatio(cluster_->tablet_server(0), &ratio);
- ASSERT_GE(ratio, 0.1) << "tserver-0";
- GetOverheadRatio(cluster_->tablet_server(1), &ratio);
- ASSERT_LE(ratio, 0.1) << "tserver-1";
- GetOverheadRatio(cluster_->tablet_server(2), &ratio);
- ASSERT_GE(ratio, 0.1) << "tserver-2";
- );
- });
+ // Sleep a long time to ensure memory consumed more.
+ SleepFor(MonoDelta::FromSeconds(8));
workload.StopAndJoin();
}
+
+ // Check result.
+ ASSERT_EVENTUALLY([&]() {
+ NO_FATALS(
+ double ratio;
+ GetOverheadRatio(cluster_->tablet_server(0), &ratio);
+ ASSERT_GE(ratio, 0.1) << "tserver-0";
+ GetOverheadRatio(cluster_->tablet_server(1), &ratio);
+ ASSERT_LE(ratio, 0.1) << "tserver-1";
+ GetOverheadRatio(cluster_->tablet_server(2), &ratio);
+ ASSERT_GE(ratio, 0.1) << "tserver-2";
+ );
+ });
}
} // namespace kudu
diff --git a/src/kudu/util/process_memory.cc b/src/kudu/util/process_memory.cc
index f395411..e236a9e 100644
--- a/src/kudu/util/process_memory.cc
+++ b/src/kudu/util/process_memory.cc
@@ -66,6 +66,10 @@ DEFINE_int32(memory_limit_warn_threshold_percentage, 98,
TAG_FLAG(memory_limit_warn_threshold_percentage, advanced);
#ifdef TCMALLOC_ENABLED
+DEFINE_bool(disable_tcmalloc_gc_by_memory_tracker_for_testing, false,
+ "For testing only! Whether to disable tcmalloc GC by memory
tracker.");
+TAG_FLAG(disable_tcmalloc_gc_by_memory_tracker_for_testing, hidden);
+
DEFINE_int32(tcmalloc_max_free_bytes_percentage, 10,
"Maximum percentage of the RSS that tcmalloc is allowed to use
for "
"reserved but unallocated memory.");
@@ -276,7 +280,8 @@ void MaybeGCAfterRelease(int64_t released_bytes) {
#ifdef TCMALLOC_ENABLED
int64_t now_released = base::subtle::NoBarrier_AtomicIncrement(
&g_released_memory_since_gc, released_bytes);
- if (PREDICT_FALSE(now_released > kGcReleaseSize)) {
+ if (PREDICT_FALSE(now_released > kGcReleaseSize
+ && !FLAGS_disable_tcmalloc_gc_by_memory_tracker_for_testing)) {
base::subtle::NoBarrier_Store(&g_released_memory_since_gc, 0);
GcTcmalloc();
}