From d0ad3c59d80c24166dd84f3b37da4a9966f1288e Mon Sep 17 00:00:00 2001 From: Peter Dillinger Date: Wed, 11 Dec 2019 15:15:34 -0800 Subject: [PATCH] Fix c_test:filter for various CACHE_LINE_SIZEs (#6153) Summary: This test was recently updated but failed to account for Bloom schema variance by CACHE_LINE_SIZE. (Since CACHE_LINE_SIZE is not defined in our C code, the test now simply allows a valid result for any CACHE_LINE_SIZE, not just the current one.) Unblock https://github.com/facebook/rocksdb/issues/5932 Pull Request resolved: https://github.com/facebook/rocksdb/pull/6153 Test Plan: ran unit test with builds TEST_CACHE_LINE_SIZE=128, =256, and unset (64 on Intel) Differential Revision: D18936015 Pulled By: pdillinger fbshipit-source-id: e5e3852f95283d34d624632c1ae8d3adb2f2662c --- db/c_test.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/db/c_test.c b/db/c_test.c index efc18f39d..993009369 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -1121,14 +1121,21 @@ int main(int argc, char** argv) { CheckGet(db, roptions, keybuf, NULL); } - // Other than the first value, these are essentially fingerprints of - // the underlying Bloom filter schemas. - static const int expected_hits[] = {5000, 241, 224}; - CheckCondition( - expected_hits[run] == - (int)rocksdb_perfcontext_metric(perf, rocksdb_bloom_sst_hit_count)); + const int hits = + (int)rocksdb_perfcontext_metric(perf, rocksdb_bloom_sst_hit_count); + if (run == 0) { + // Due to half true, half false with fake filter result + CheckCondition(hits == keys_to_query / 2); + } else if (run == 1) { + // Essentially a fingerprint of the block-based Bloom schema + CheckCondition(hits == 241); + } else { + // Essentially a fingerprint of the full Bloom schema(s), + // format_version < 5, which vary for three different CACHE_LINE_SIZEs + CheckCondition(hits == 224 || hits == 180 || hits == 125); + } CheckCondition( - (keys_to_query - expected_hits[run]) == + (keys_to_query - hits) == (int)rocksdb_perfcontext_metric(perf, rocksdb_bloom_sst_miss_count)); rocksdb_perfcontext_destroy(perf);