bloom_impl.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. // Copyright (c) 2019-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. //
  6. // Implementation details of various Bloom filter implementations used in
  7. // RocksDB. (DynamicBloom is in a separate file for now because it
  8. // supports concurrent write.)
  9. #pragma once
  10. #include <stddef.h>
  11. #include <stdint.h>
  12. #include <cmath>
  13. #include "rocksdb/slice.h"
  14. #include "util/hash.h"
  15. #ifdef HAVE_AVX2
  16. #include <immintrin.h>
  17. #endif
  18. namespace ROCKSDB_NAMESPACE {
  19. class BloomMath {
  20. public:
  21. // False positive rate of a standard Bloom filter, for given ratio of
  22. // filter memory bits to added keys, and number of probes per operation.
  23. // (The false positive rate is effectively independent of scale, assuming
  24. // the implementation scales OK.)
  25. static double StandardFpRate(double bits_per_key, int num_probes) {
  26. // Standard very-good-estimate formula. See
  27. // https://en.wikipedia.org/wiki/Bloom_filter#Probability_of_false_positives
  28. return std::pow(1.0 - std::exp(-num_probes / bits_per_key), num_probes);
  29. }
  30. // False positive rate of a "blocked"/"shareded"/"cache-local" Bloom filter,
  31. // for given ratio of filter memory bits to added keys, number of probes per
  32. // operation (all within the given block or cache line size), and block or
  33. // cache line size.
  34. static double CacheLocalFpRate(double bits_per_key, int num_probes,
  35. int cache_line_bits) {
  36. double keys_per_cache_line = cache_line_bits / bits_per_key;
  37. // A reasonable estimate is the average of the FP rates for one standard
  38. // deviation above and below the mean bucket occupancy. See
  39. // https://github.com/facebook/rocksdb/wiki/RocksDB-Bloom-Filter#the-math
  40. double keys_stddev = std::sqrt(keys_per_cache_line);
  41. double crowded_fp = StandardFpRate(
  42. cache_line_bits / (keys_per_cache_line + keys_stddev), num_probes);
  43. double uncrowded_fp = StandardFpRate(
  44. cache_line_bits / (keys_per_cache_line - keys_stddev), num_probes);
  45. return (crowded_fp + uncrowded_fp) / 2;
  46. }
  47. // False positive rate of querying a new item against `num_keys` items, all
  48. // hashed to `fingerprint_bits` bits. (This assumes the fingerprint hashes
  49. // themselves are stored losslessly. See Section 4 of
  50. // http://www.ccs.neu.edu/home/pete/pub/bloom-filters-verification.pdf)
  51. static double FingerprintFpRate(size_t num_keys, int fingerprint_bits) {
  52. double inv_fingerprint_space = std::pow(0.5, fingerprint_bits);
  53. // Base estimate assumes each key maps to a unique fingerprint.
  54. // Could be > 1 in extreme cases.
  55. double base_estimate = num_keys * inv_fingerprint_space;
  56. // To account for potential overlap, we choose between two formulas
  57. if (base_estimate > 0.0001) {
  58. // A very good formula assuming we don't construct a floating point
  59. // number extremely close to 1. Always produces a probability < 1.
  60. return 1.0 - std::exp(-base_estimate);
  61. } else {
  62. // A very good formula when base_estimate is far below 1. (Subtract
  63. // away the integral-approximated sum that some key has same hash as
  64. // one coming before it in a list.)
  65. return base_estimate - (base_estimate * base_estimate * 0.5);
  66. }
  67. }
  68. // Returns the probably of either of two independent(-ish) events
  69. // happening, given their probabilities. (This is useful for combining
  70. // results from StandardFpRate or CacheLocalFpRate with FingerprintFpRate
  71. // for a hash-efficient Bloom filter's FP rate. See Section 4 of
  72. // http://www.ccs.neu.edu/home/pete/pub/bloom-filters-verification.pdf)
  73. static double IndependentProbabilitySum(double rate1, double rate2) {
  74. // Use formula that avoids floating point extremely close to 1 if
  75. // rates are extremely small.
  76. return rate1 + rate2 - (rate1 * rate2);
  77. }
  78. };
  79. // A fast, flexible, and accurate cache-local Bloom implementation with
  80. // SIMD-optimized query performance (currently using AVX2 on Intel). Write
  81. // performance and non-SIMD read are very good, benefiting from fastrange32
  82. // used in place of % and single-cycle multiplication on recent processors.
  83. //
  84. // Most other SIMD Bloom implementations sacrifice flexibility and/or
  85. // accuracy by requiring num_probes to be a power of two and restricting
  86. // where each probe can occur in a cache line. This implementation sacrifices
  87. // SIMD-optimization for add (might still be possible, especially with AVX512)
  88. // in favor of allowing any num_probes, not crossing cache line boundary,
  89. // and accuracy close to theoretical best accuracy for a cache-local Bloom.
  90. // E.g. theoretical best for 10 bits/key, num_probes=6, and 512-bit bucket
  91. // (Intel cache line size) is 0.9535% FP rate. This implementation yields
  92. // about 0.957%. (Compare to LegacyLocalityBloomImpl<false> at 1.138%, or
  93. // about 0.951% for 1024-bit buckets, cache line size for some ARM CPUs.)
  94. //
  95. // This implementation can use a 32-bit hash (let h2 be h1 * 0x9e3779b9) or
  96. // a 64-bit hash (split into two uint32s). With many millions of keys, the
  97. // false positive rate associated with using a 32-bit hash can dominate the
  98. // false positive rate of the underlying filter. At 10 bits/key setting, the
  99. // inflection point is about 40 million keys, so 32-bit hash is a bad idea
  100. // with 10s of millions of keys or more.
  101. //
  102. // Despite accepting a 64-bit hash, this implementation uses 32-bit fastrange
  103. // to pick a cache line, which can be faster than 64-bit in some cases.
  104. // This only hurts accuracy as you get into 10s of GB for a single filter,
  105. // and accuracy abruptly breaks down at 256GB (2^32 cache lines). Switch to
  106. // 64-bit fastrange if you need filters so big. ;)
  107. //
  108. // Using only a 32-bit input hash within each cache line has negligible
  109. // impact for any reasonable cache line / bucket size, for arbitrary filter
  110. // size, and potentially saves intermediate data size in some cases vs.
  111. // tracking full 64 bits. (Even in an implementation using 64-bit arithmetic
  112. // to generate indices, I might do the same, as a single multiplication
  113. // suffices to generate a sufficiently mixed 64 bits from 32 bits.)
  114. //
  115. // This implementation is currently tied to Intel cache line size, 64 bytes ==
  116. // 512 bits. If there's sufficient demand for other cache line sizes, this is
  117. // a pretty good implementation to extend, but slight performance enhancements
  118. // are possible with an alternate implementation (probably not very compatible
  119. // with SIMD):
  120. // (1) Use rotation in addition to multiplication for remixing
  121. // (like murmur hash). (Using multiplication alone *slightly* hurts accuracy
  122. // because lower bits never depend on original upper bits.)
  123. // (2) Extract more than one bit index from each re-mix. (Only if rotation
  124. // or similar is part of remix, because otherwise you're making the
  125. // multiplication-only problem worse.)
  126. // (3) Re-mix full 64 bit hash, to get maximum number of bit indices per
  127. // re-mix.
  128. //
  129. class FastLocalBloomImpl {
  130. public:
  131. // NOTE: this has only been validated to enough accuracy for producing
  132. // reasonable warnings / user feedback, not for making functional decisions.
  133. static double EstimatedFpRate(size_t keys, size_t bytes, int num_probes,
  134. int hash_bits) {
  135. return BloomMath::IndependentProbabilitySum(
  136. BloomMath::CacheLocalFpRate(8.0 * bytes / keys, num_probes,
  137. /*cache line bits*/ 512),
  138. BloomMath::FingerprintFpRate(keys, hash_bits));
  139. }
  140. static inline int ChooseNumProbes(int millibits_per_key) {
  141. // Since this implementation can (with AVX2) make up to 8 probes
  142. // for the same cost, we pick the most accurate num_probes, based
  143. // on actual tests of the implementation. Note that for higher
  144. // bits/key, the best choice for cache-local Bloom can be notably
  145. // smaller than standard bloom, e.g. 9 instead of 11 @ 16 b/k.
  146. if (millibits_per_key <= 2080) {
  147. return 1;
  148. } else if (millibits_per_key <= 3580) {
  149. return 2;
  150. } else if (millibits_per_key <= 5100) {
  151. return 3;
  152. } else if (millibits_per_key <= 6640) {
  153. return 4;
  154. } else if (millibits_per_key <= 8300) {
  155. return 5;
  156. } else if (millibits_per_key <= 10070) {
  157. return 6;
  158. } else if (millibits_per_key <= 11720) {
  159. return 7;
  160. } else if (millibits_per_key <= 14001) {
  161. // Would be something like <= 13800 but sacrificing *slightly* for
  162. // more settings using <= 8 probes.
  163. return 8;
  164. } else if (millibits_per_key <= 16050) {
  165. return 9;
  166. } else if (millibits_per_key <= 18300) {
  167. return 10;
  168. } else if (millibits_per_key <= 22001) {
  169. return 11;
  170. } else if (millibits_per_key <= 25501) {
  171. return 12;
  172. } else if (millibits_per_key > 50000) {
  173. // Top out at 24 probes (three sets of 8)
  174. return 24;
  175. } else {
  176. // Roughly optimal choices for remaining range
  177. // e.g.
  178. // 28000 -> 12, 28001 -> 13
  179. // 50000 -> 23, 50001 -> 24
  180. return (millibits_per_key - 1) / 2000 - 1;
  181. }
  182. }
  183. static inline void AddHash(uint32_t h1, uint32_t h2, uint32_t len_bytes,
  184. int num_probes, char *data) {
  185. uint32_t bytes_to_cache_line = fastrange32(len_bytes >> 6, h1) << 6;
  186. AddHashPrepared(h2, num_probes, data + bytes_to_cache_line);
  187. }
  188. static inline void AddHashPrepared(uint32_t h2, int num_probes,
  189. char *data_at_cache_line) {
  190. uint32_t h = h2;
  191. for (int i = 0; i < num_probes; ++i, h *= uint32_t{0x9e3779b9}) {
  192. // 9-bit address within 512 bit cache line
  193. int bitpos = h >> (32 - 9);
  194. data_at_cache_line[bitpos >> 3] |= (uint8_t{1} << (bitpos & 7));
  195. }
  196. }
  197. static inline void PrepareHash(uint32_t h1, uint32_t len_bytes,
  198. const char *data,
  199. uint32_t /*out*/ *byte_offset) {
  200. uint32_t bytes_to_cache_line = fastrange32(len_bytes >> 6, h1) << 6;
  201. PREFETCH(data + bytes_to_cache_line, 0 /* rw */, 1 /* locality */);
  202. PREFETCH(data + bytes_to_cache_line + 63, 0 /* rw */, 1 /* locality */);
  203. *byte_offset = bytes_to_cache_line;
  204. }
  205. static inline bool HashMayMatch(uint32_t h1, uint32_t h2, uint32_t len_bytes,
  206. int num_probes, const char *data) {
  207. uint32_t bytes_to_cache_line = fastrange32(len_bytes >> 6, h1) << 6;
  208. return HashMayMatchPrepared(h2, num_probes, data + bytes_to_cache_line);
  209. }
  210. static inline bool HashMayMatchPrepared(uint32_t h2, int num_probes,
  211. const char *data_at_cache_line) {
  212. uint32_t h = h2;
  213. #ifdef HAVE_AVX2
  214. int rem_probes = num_probes;
  215. // NOTE: For better performance for num_probes in {1, 2, 9, 10, 17, 18,
  216. // etc.} one can insert specialized code for rem_probes <= 2, bypassing
  217. // the SIMD code in those cases. There is a detectable but minor overhead
  218. // applied to other values of num_probes (when not statically determined),
  219. // but smoother performance curve vs. num_probes. But for now, when
  220. // in doubt, don't add unnecessary code.
  221. // Powers of 32-bit golden ratio, mod 2**32.
  222. const __m256i multipliers =
  223. _mm256_setr_epi32(0x00000001, 0x9e3779b9, 0xe35e67b1, 0x734297e9,
  224. 0x35fbe861, 0xdeb7c719, 0x448b211, 0x3459b749);
  225. for (;;) {
  226. // Eight copies of hash
  227. __m256i hash_vector = _mm256_set1_epi32(h);
  228. // Same effect as repeated multiplication by 0x9e3779b9 thanks to
  229. // associativity of multiplication.
  230. hash_vector = _mm256_mullo_epi32(hash_vector, multipliers);
  231. // Now the top 9 bits of each of the eight 32-bit values in
  232. // hash_vector are bit addresses for probes within the cache line.
  233. // While the platform-independent code uses byte addressing (6 bits
  234. // to pick a byte + 3 bits to pick a bit within a byte), here we work
  235. // with 32-bit words (4 bits to pick a word + 5 bits to pick a bit
  236. // within a word) because that works well with AVX2 and is equivalent
  237. // under little-endian.
  238. // Shift each right by 28 bits to get 4-bit word addresses.
  239. const __m256i word_addresses = _mm256_srli_epi32(hash_vector, 28);
  240. // Gather 32-bit values spread over 512 bits by 4-bit address. In
  241. // essence, we are dereferencing eight pointers within the cache
  242. // line.
  243. //
  244. // Option 1: AVX2 gather (seems to be a little slow - understandable)
  245. // const __m256i value_vector =
  246. // _mm256_i32gather_epi32(static_cast<const int
  247. // *>(data_at_cache_line),
  248. // word_addresses,
  249. // /*bytes / i32*/ 4);
  250. // END Option 1
  251. // Potentially unaligned as we're not *always* cache-aligned -> loadu
  252. const __m256i *mm_data =
  253. reinterpret_cast<const __m256i *>(data_at_cache_line);
  254. __m256i lower = _mm256_loadu_si256(mm_data);
  255. __m256i upper = _mm256_loadu_si256(mm_data + 1);
  256. // Option 2: AVX512VL permute hack
  257. // Only negligibly faster than Option 3, so not yet worth supporting
  258. // const __m256i value_vector =
  259. // _mm256_permutex2var_epi32(lower, word_addresses, upper);
  260. // END Option 2
  261. // Option 3: AVX2 permute+blend hack
  262. // Use lowest three bits to order probing values, as if all from same
  263. // 256 bit piece.
  264. lower = _mm256_permutevar8x32_epi32(lower, word_addresses);
  265. upper = _mm256_permutevar8x32_epi32(upper, word_addresses);
  266. // Just top 1 bit of address, to select between lower and upper.
  267. const __m256i upper_lower_selector = _mm256_srai_epi32(hash_vector, 31);
  268. // Finally: the next 8 probed 32-bit values, in probing sequence order.
  269. const __m256i value_vector =
  270. _mm256_blendv_epi8(lower, upper, upper_lower_selector);
  271. // END Option 3
  272. // We might not need to probe all 8, so build a mask for selecting only
  273. // what we need. (The k_selector(s) could be pre-computed but that
  274. // doesn't seem to make a noticeable performance difference.)
  275. const __m256i zero_to_seven = _mm256_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7);
  276. // Subtract rem_probes from each of those constants
  277. __m256i k_selector =
  278. _mm256_sub_epi32(zero_to_seven, _mm256_set1_epi32(rem_probes));
  279. // Negative after subtract -> use/select
  280. // Keep only high bit (logical shift right each by 31).
  281. k_selector = _mm256_srli_epi32(k_selector, 31);
  282. // Strip off the 4 bit word address (shift left)
  283. __m256i bit_addresses = _mm256_slli_epi32(hash_vector, 4);
  284. // And keep only 5-bit (32 - 27) bit-within-32-bit-word addresses.
  285. bit_addresses = _mm256_srli_epi32(bit_addresses, 27);
  286. // Build a bit mask
  287. const __m256i bit_mask = _mm256_sllv_epi32(k_selector, bit_addresses);
  288. // Like ((~value_vector) & bit_mask) == 0)
  289. bool match = _mm256_testc_si256(value_vector, bit_mask) != 0;
  290. // This check first so that it's easy for branch predictor to optimize
  291. // num_probes <= 8 case, making it free of unpredictable branches.
  292. if (rem_probes <= 8) {
  293. return match;
  294. } else if (!match) {
  295. return false;
  296. }
  297. // otherwise
  298. // Need another iteration. 0xab25f4c1 == golden ratio to the 8th power
  299. h *= 0xab25f4c1;
  300. rem_probes -= 8;
  301. }
  302. #else
  303. for (int i = 0; i < num_probes; ++i, h *= uint32_t{0x9e3779b9}) {
  304. // 9-bit address within 512 bit cache line
  305. int bitpos = h >> (32 - 9);
  306. if ((data_at_cache_line[bitpos >> 3] & (char(1) << (bitpos & 7))) == 0) {
  307. return false;
  308. }
  309. }
  310. return true;
  311. #endif
  312. }
  313. };
  314. // A legacy Bloom filter implementation with no locality of probes (slow).
  315. // It uses double hashing to generate a sequence of hash values.
  316. // Asymptotic analysis is in [Kirsch,Mitzenmacher 2006], but known to have
  317. // subtle accuracy flaws for practical sizes [Dillinger,Manolios 2004].
  318. //
  319. // DO NOT REUSE
  320. //
  321. class LegacyNoLocalityBloomImpl {
  322. public:
  323. static inline int ChooseNumProbes(int bits_per_key) {
  324. // We intentionally round down to reduce probing cost a little bit
  325. int num_probes = static_cast<int>(bits_per_key * 0.69); // 0.69 =~ ln(2)
  326. if (num_probes < 1) num_probes = 1;
  327. if (num_probes > 30) num_probes = 30;
  328. return num_probes;
  329. }
  330. static inline void AddHash(uint32_t h, uint32_t total_bits, int num_probes,
  331. char *data) {
  332. const uint32_t delta = (h >> 17) | (h << 15); // Rotate right 17 bits
  333. for (int i = 0; i < num_probes; i++) {
  334. const uint32_t bitpos = h % total_bits;
  335. data[bitpos / 8] |= (1 << (bitpos % 8));
  336. h += delta;
  337. }
  338. }
  339. static inline bool HashMayMatch(uint32_t h, uint32_t total_bits,
  340. int num_probes, const char *data) {
  341. const uint32_t delta = (h >> 17) | (h << 15); // Rotate right 17 bits
  342. for (int i = 0; i < num_probes; i++) {
  343. const uint32_t bitpos = h % total_bits;
  344. if ((data[bitpos / 8] & (1 << (bitpos % 8))) == 0) {
  345. return false;
  346. }
  347. h += delta;
  348. }
  349. return true;
  350. }
  351. };
  352. // A legacy Bloom filter implementation with probes local to a single
  353. // cache line (fast). Because SST files might be transported between
  354. // platforms, the cache line size is a parameter rather than hard coded.
  355. // (But if specified as a constant parameter, an optimizing compiler
  356. // should take advantage of that.)
  357. //
  358. // When ExtraRotates is false, this implementation is notably deficient in
  359. // accuracy. Specifically, it uses double hashing with a 1/512 chance of the
  360. // increment being zero (when cache line size is 512 bits). Thus, there's a
  361. // 1/512 chance of probing only one index, which we'd expect to incur about
  362. // a 1/2 * 1/512 or absolute 0.1% FP rate penalty. More detail at
  363. // https://github.com/facebook/rocksdb/issues/4120
  364. //
  365. // DO NOT REUSE
  366. //
  367. template <bool ExtraRotates>
  368. class LegacyLocalityBloomImpl {
  369. private:
  370. static inline uint32_t GetLine(uint32_t h, uint32_t num_lines) {
  371. uint32_t offset_h = ExtraRotates ? (h >> 11) | (h << 21) : h;
  372. return offset_h % num_lines;
  373. }
  374. public:
  375. // NOTE: this has only been validated to enough accuracy for producing
  376. // reasonable warnings / user feedback, not for making functional decisions.
  377. static double EstimatedFpRate(size_t keys, size_t bytes, int num_probes) {
  378. double bits_per_key = 8.0 * bytes / keys;
  379. double filter_rate = BloomMath::CacheLocalFpRate(bits_per_key, num_probes,
  380. /*cache line bits*/ 512);
  381. if (!ExtraRotates) {
  382. // Good estimate of impact of flaw in index computation.
  383. // Adds roughly 0.002 around 50 bits/key and 0.001 around 100 bits/key.
  384. // The + 22 shifts it nicely to fit for lower bits/key.
  385. filter_rate += 0.1 / (bits_per_key * 0.75 + 22);
  386. } else {
  387. // Not yet validated
  388. assert(false);
  389. }
  390. // Always uses 32-bit hash
  391. double fingerprint_rate = BloomMath::FingerprintFpRate(keys, 32);
  392. return BloomMath::IndependentProbabilitySum(filter_rate, fingerprint_rate);
  393. }
  394. static inline void AddHash(uint32_t h, uint32_t num_lines, int num_probes,
  395. char *data, int log2_cache_line_bytes) {
  396. const int log2_cache_line_bits = log2_cache_line_bytes + 3;
  397. char *data_at_offset =
  398. data + (GetLine(h, num_lines) << log2_cache_line_bytes);
  399. const uint32_t delta = (h >> 17) | (h << 15);
  400. for (int i = 0; i < num_probes; ++i) {
  401. // Mask to bit-within-cache-line address
  402. const uint32_t bitpos = h & ((1 << log2_cache_line_bits) - 1);
  403. data_at_offset[bitpos / 8] |= (1 << (bitpos % 8));
  404. if (ExtraRotates) {
  405. h = (h >> log2_cache_line_bits) | (h << (32 - log2_cache_line_bits));
  406. }
  407. h += delta;
  408. }
  409. }
  410. static inline void PrepareHashMayMatch(uint32_t h, uint32_t num_lines,
  411. const char *data,
  412. uint32_t /*out*/ *byte_offset,
  413. int log2_cache_line_bytes) {
  414. uint32_t b = GetLine(h, num_lines) << log2_cache_line_bytes;
  415. PREFETCH(data + b, 0 /* rw */, 1 /* locality */);
  416. PREFETCH(data + b + ((1 << log2_cache_line_bytes) - 1), 0 /* rw */,
  417. 1 /* locality */);
  418. *byte_offset = b;
  419. }
  420. static inline bool HashMayMatch(uint32_t h, uint32_t num_lines,
  421. int num_probes, const char *data,
  422. int log2_cache_line_bytes) {
  423. uint32_t b = GetLine(h, num_lines) << log2_cache_line_bytes;
  424. return HashMayMatchPrepared(h, num_probes, data + b, log2_cache_line_bytes);
  425. }
  426. static inline bool HashMayMatchPrepared(uint32_t h, int num_probes,
  427. const char *data_at_offset,
  428. int log2_cache_line_bytes) {
  429. const int log2_cache_line_bits = log2_cache_line_bytes + 3;
  430. const uint32_t delta = (h >> 17) | (h << 15);
  431. for (int i = 0; i < num_probes; ++i) {
  432. // Mask to bit-within-cache-line address
  433. const uint32_t bitpos = h & ((1 << log2_cache_line_bits) - 1);
  434. if (((data_at_offset[bitpos / 8]) & (1 << (bitpos % 8))) == 0) {
  435. return false;
  436. }
  437. if (ExtraRotates) {
  438. h = (h >> log2_cache_line_bits) | (h << (32 - log2_cache_line_bits));
  439. }
  440. h += delta;
  441. }
  442. return true;
  443. }
  444. };
  445. } // namespace ROCKSDB_NAMESPACE