mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-25 14:31:35 +00:00
653c392e47
Summary: I'm working on a new format_version=6 to support context checksum (https://github.com/facebook/rocksdb/issues/9058) and this includes much of the refactoring and test updates to support that change. Test coverage data and manual inspection agree on dead code in block_based_table_reader.cc (removed). Pull Request resolved: https://github.com/facebook/rocksdb/pull/9240 Test Plan: tests enhanced to cover more cases etc. Extreme case performance testing indicates small % regression in fillseq (w/ compaction), though CPU profile etc. doesn't suggest any explanation. There is enhanced correctness checking in Footer::DecodeFrom, but this should be negligible. TEST_TMPDIR=/dev/shm/ ./db_bench -benchmarks=fillseq -memtablerep=vector -allow_concurrent_memtable_write=false -num=30000000 -checksum_type=1 --disable_wal={false,true} (Each is ops/s averaged over 50 runs, run simultaneously with competing configuration for load fairness) Before w/ wal: 454512 After w/ wal: 444820 (-2.1%) Before w/o wal: 1004560 After w/o wal: 998897 (-0.6%) Since this doesn't modify WAL code, one would expect real effects to be larger in w/o wal case. This regression will be corrected in a follow-up PR. Reviewed By: ajkr Differential Revision: D32813769 Pulled By: pdillinger fbshipit-source-id: 444a244eabf3825cd329b7d1b150cddce320862f
43 lines
1.7 KiB
C++
43 lines
1.7 KiB
C++
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
|
|
#pragma once
|
|
|
|
#include <type_traits>
|
|
|
|
#include "rocksdb/rocksdb_namespace.h"
|
|
|
|
namespace ROCKSDB_NAMESPACE {
|
|
// The helper function to assert the move from dynamic_cast<> to
|
|
// static_cast<> is correct. This function is to deal with legacy code.
|
|
// It is not recommended to add new code to issue class casting. The preferred
|
|
// solution is to implement the functionality without a need of casting.
|
|
template <class DestClass, class SrcClass>
|
|
inline DestClass* static_cast_with_check(SrcClass* x) {
|
|
DestClass* ret = static_cast<DestClass*>(x);
|
|
#ifdef ROCKSDB_USE_RTTI
|
|
assert(ret == dynamic_cast<DestClass*>(x));
|
|
#endif
|
|
return ret;
|
|
}
|
|
|
|
// A wrapper around static_cast for lossless conversion between integral
|
|
// types, including enum types. For example, this can be used for converting
|
|
// between signed/unsigned or enum type and underlying type without fear of
|
|
// stripping away data, now or in the future.
|
|
template <typename To, typename From>
|
|
inline To lossless_cast(From x) {
|
|
using FromValue = typename std::remove_reference<From>::type;
|
|
static_assert(
|
|
std::is_integral<FromValue>::value || std::is_enum<FromValue>::value,
|
|
"Only works on integral types");
|
|
static_assert(std::is_integral<To>::value || std::is_enum<To>::value,
|
|
"Only works on integral types");
|
|
static_assert(sizeof(To) >= sizeof(FromValue), "Must be lossless");
|
|
return static_cast<To>(x);
|
|
}
|
|
|
|
} // namespace ROCKSDB_NAMESPACE
|