summaryrefslogtreecommitdiff
path: root/third-party
diff options
context:
space:
mode:
authorPeter Dillinger <peterd@fb.com>2019-09-16 16:15:18 -0700
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>2019-09-16 16:17:09 -0700
commit68626249c3551bd31ba8712ba0fc86f31f00890c (patch)
tree4d502cf7dc59eb0ae7643b8035eadc886f1aec1d /third-party
parent638d23950716f3119057d725fbbf1590b807a849 (diff)
Refactor/consolidate legacy Bloom implementation details (#5784)
Summary: Refactoring to consolidate implementation details of legacy Bloom filters. This helps to organize and document some related, obscure code. Also added make/cpp var TEST_CACHE_LINE_SIZE so that it's easy to compile and run unit tests for non-native cache line size. (Fixed a related test failure in db_properties_test.) Pull Request resolved: https://github.com/facebook/rocksdb/pull/5784 Test Plan: make check, including Recently added Bloom schema unit tests (in ./plain_table_db_test && ./bloom_test), and including with TEST_CACHE_LINE_SIZE=128U and TEST_CACHE_LINE_SIZE=256U. Tested the schema tests with temporary fault injection into new implementations. Some performance testing with modified unit tests suggest a small to moderate improvement in speed. Differential Revision: D17381384 Pulled By: pdillinger fbshipit-source-id: ee42586da996798910fc45ac0b6289147f16d8df
Diffstat (limited to 'third-party')
-rw-r--r--third-party/folly/folly/ConstexprMath.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/third-party/folly/folly/ConstexprMath.h b/third-party/folly/folly/ConstexprMath.h
index b125c5f42..f09167e0d 100644
--- a/third-party/folly/folly/ConstexprMath.h
+++ b/third-party/folly/folly/ConstexprMath.h
@@ -14,4 +14,32 @@ template <typename T, typename... Ts>
constexpr T constexpr_max(T a, T b, Ts... ts) {
return b < a ? constexpr_max(a, ts...) : constexpr_max(b, ts...);
}
+
+namespace detail {
+template <typename T>
+constexpr T constexpr_log2_(T a, T e) {
+ return e == T(1) ? a : constexpr_log2_(a + T(1), e / T(2));
+}
+
+template <typename T>
+constexpr T constexpr_log2_ceil_(T l2, T t) {
+ return l2 + T(T(1) << l2 < t ? 1 : 0);
+}
+
+template <typename T>
+constexpr T constexpr_square_(T t) {
+ return t * t;
+}
+} // namespace detail
+
+template <typename T>
+constexpr T constexpr_log2(T t) {
+ return detail::constexpr_log2_(T(0), t);
+}
+
+template <typename T>
+constexpr T constexpr_log2_ceil(T t) {
+ return detail::constexpr_log2_ceil_(constexpr_log2(t), t);
+}
+
} // namespace folly