Deflake^2 DBBloomFilterTest.OptimizeFiltersForHits (#10816)

Summary:
This reverts https://github.com/facebook/rocksdb/issues/10792 and uses a different strategy to stabilize the test: remove the unnecessary randomness by providing a constant seed for shuffling keys.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10816

Test Plan: `gtest-parallel ./db_bloom_filter_test -r1000 --gtest_filter=*ForHits*`

Reviewed By: jay-zhuang

Differential Revision: D40347957

Pulled By: pdillinger

fbshipit-source-id: a270e157485cbd94ed03b80cdd21b954ebd57d57
main
Peter Dillinger 2 years ago committed by Facebook GitHub Bot
parent a2eea18fc9
commit 1ee747d795
  1. 6
      db/db_bloom_filter_test.cc

@ -2496,7 +2496,7 @@ TEST_F(DBBloomFilterTest, OptimizeFiltersForHits) {
for (int i = 0; i < numkeys; i += 2) { for (int i = 0; i < numkeys; i += 2) {
keys.push_back(i); keys.push_back(i);
} }
RandomShuffle(std::begin(keys), std::end(keys)); RandomShuffle(std::begin(keys), std::end(keys), /*seed*/ 42);
int num_inserted = 0; int num_inserted = 0;
for (int key : keys) { for (int key : keys) {
ASSERT_OK(Put(1, Key(key), "val")); ASSERT_OK(Put(1, Key(key), "val"));
@ -2528,9 +2528,7 @@ TEST_F(DBBloomFilterTest, OptimizeFiltersForHits) {
// Now we have three sorted run, L0, L5 and L6 with most files in L6 have // Now we have three sorted run, L0, L5 and L6 with most files in L6 have
// no bloom filter. Most keys be checked bloom filters twice. // no bloom filter. Most keys be checked bloom filters twice.
// But L5 SSTs may only cover small range of keys, so only L0 filter is ASSERT_GT(TestGetTickerCount(options, BLOOM_FILTER_USEFUL), 65000 * 2);
// guaranteed to be hit (USEFUL).
ASSERT_GE(TestGetTickerCount(options, BLOOM_FILTER_USEFUL), 100000);
ASSERT_LT(TestGetTickerCount(options, BLOOM_FILTER_USEFUL), 120000 * 2); ASSERT_LT(TestGetTickerCount(options, BLOOM_FILTER_USEFUL), 120000 * 2);
uint64_t bloom_filter_useful_all_levels = 0; uint64_t bloom_filter_useful_all_levels = 0;
for (auto& kv : (*(get_perf_context()->level_to_perf_context))) { for (auto& kv : (*(get_perf_context()->level_to_perf_context))) {

Loading…
Cancel
Save