From 73d71470966b2681e802a9edcc81094b0a196d3c Mon Sep 17 00:00:00 2001 From: Lei Jin Date: Tue, 8 Jul 2014 15:15:00 -0700 Subject: [PATCH] make rate limiter test more reliable Summary: Randomize keys so that compaction actually happens. Change the config so that compaction happens more aggressively. The test takes longer time, but the results are more stable shown by iostat Test Plan: ran it Reviewers: igor, yhchiang Reviewed By: yhchiang Subscribers: leveldb Differential Revision: https://reviews.facebook.net/D19533 --- db/db_test.cc | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/db/db_test.cc b/db/db_test.cc index 23f6bc1e2..6163b55ed 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -7135,21 +7135,27 @@ TEST(DBTest, MTRandomTimeoutTest) { TEST(DBTest, RateLimitingTest) { Options options = CurrentOptions(); - options.write_buffer_size = 1 << 20; // 1MB - options.level0_file_num_compaction_trigger = 10; - options.target_file_size_base = 1 << 20; // 1MB - options.max_bytes_for_level_base = 10 << 20; // 10MB + options.write_buffer_size = 1 << 20; // 1MB + options.level0_file_num_compaction_trigger = 2; + options.target_file_size_base = 1 << 20; // 1MB + options.max_bytes_for_level_base = 4 << 20; // 4MB + options.max_bytes_for_level_multiplier = 4; options.compression = kNoCompression; options.create_if_missing = true; options.env = env_; + options.IncreaseParallelism(4); DestroyAndReopen(&options); + WriteOptions wo; + wo.disableWAL = true; + // # no rate limiting Random rnd(301); uint64_t start = env_->NowMicros(); - // Write ~32M data - for (int64_t i = 0; i < (32 << 10); ++i) { - ASSERT_OK(Put(std::to_string(i), RandomString(&rnd, (1 << 10) + 1))); + // Write ~96M data + for (int64_t i = 0; i < (96 << 10); ++i) { + ASSERT_OK(Put(RandomString(&rnd, 32), + RandomString(&rnd, (1 << 10) + 1), wo)); } uint64_t elapsed = env_->NowMicros() - start; double raw_rate = env_->bytes_written_ * 1000000 / elapsed; @@ -7162,9 +7168,10 @@ TEST(DBTest, RateLimitingTest) { DestroyAndReopen(&options); start = env_->NowMicros(); - // Write ~32M data - for (int64_t i = 0; i < (32 << 10); ++i) { - ASSERT_OK(Put(std::to_string(i), RandomString(&rnd, (1 << 10) + 1))); + // Write ~96M data + for (int64_t i = 0; i < (96 << 10); ++i) { + ASSERT_OK(Put(RandomString(&rnd, 32), + RandomString(&rnd, (1 << 10) + 1), wo)); } elapsed = env_->NowMicros() - start; Close(); @@ -7181,9 +7188,10 @@ TEST(DBTest, RateLimitingTest) { DestroyAndReopen(&options); start = env_->NowMicros(); - // Write ~32M data - for (int64_t i = 0; i < (32 << 10); ++i) { - ASSERT_OK(Put(std::to_string(i), RandomString(&rnd, (1 << 10) + 1))); + // Write ~96M data + for (int64_t i = 0; i < (96 << 10); ++i) { + ASSERT_OK(Put(RandomString(&rnd, 32), + RandomString(&rnd, (1 << 10) + 1), wo)); } elapsed = env_->NowMicros() - start; Close();