Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Branch: merge master to planner_refactory branch #5034

Merged
merged 24 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
973de13
Refine function test framework (#4861)
windtalker May 26, 2022
f10b6d2
Add mutex to protect exchange receiver's async client (#5008)
yibin87 May 26, 2022
d84f273
Optimize blobstore gc when current stat total size is 0 (#5015)
jiaqizho May 27, 2022
ca3e1c6
Fix an invalid default value cause bootstrap failed (#4916)
Lloyd-Pottiger May 27, 2022
d1ecebd
PageStorage: Report the file usage of BlobStore (#4999)
JaySon-Huang May 27, 2022
7dff463
Fix unstable ut in the master branch (#5024)
hehechen May 27, 2022
c8624a0
refine get type from decimal literal (#5014)
windtalker May 30, 2022
516fa15
Refactor: add new module schema (#4932)
hzh0425 May 30, 2022
335b124
docs: Add rfc for compact table via sql (#4929)
breezewish May 30, 2022
580821a
Fix broken unit test for `--gtest_filter='*StorageDeltaMergeTest*:*Re…
JaySon-Huang May 30, 2022
6afdd74
Remove useless code (#5004)
hongyunyan May 31, 2022
a0ed1a6
Add mix mode UT (#5012)
hehechen May 31, 2022
800715c
support mix_mode in dt_workload (#5011)
lidezhu Jun 1, 2022
380f6cd
enable new function test framework by default (#5029)
windtalker Jun 1, 2022
187a591
Tiflash pagectl support encrypted data (#5003)
hehechen Jun 1, 2022
226dff6
update tiflash proxy (#5043)
Lloyd-Pottiger Jun 2, 2022
2ce9529
Fix potential data inconsistency under heavy ddl operation (#5044)
lidezhu Jun 2, 2022
20d2198
*: fix invalid fmt format string in CreatingSetsBlockInputStream.cpp …
ywqzzy Jun 2, 2022
677ad75
increase bg gc check interval (#5056)
lidezhu Jun 3, 2022
b49a787
PageStorage: Fix pages are not deleted under some cases (#5069)
JaySon-Huang Jun 3, 2022
a66c082
Fix unstable drop table unit test (#5059)
lidezhu Jun 3, 2022
e3a4412
Fix broken ut SegmentDeletionRelevantPlaceTest (#4607)
JaySon-Huang Jun 6, 2022
5847f1c
Add `Precompiled header` for modules & Refine by PImpl to accelerate …
solotzg Jun 8, 2022
fdab3f5
Test: Mock Input columns for operator tests (#5041)
ywqzzy Jun 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ endif ()
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)

option (USE_CCACHE "Set to OFF to disable ccache" ON)
if (USE_CCACHE)
set(NOT_USE_CCACHE 0)
else()
set(NOT_USE_CCACHE 1)
endif()

option(ENABLE_PCH "Enable `Precompiled header`" OFF)

include (cmake/find_ccache.cmake)

if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "None")
Expand Down
14 changes: 14 additions & 0 deletions cmake/find_ccache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ if (USE_CCACHE AND CCACHE_FOUND AND NOT CMAKE_CXX_COMPILER_LAUNCHER MATCHES "cca
message ("${CCACHE_CONFIG}")
set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_FOUND})
set_property (GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_FOUND})

if (ENABLE_PCH)
execute_process (COMMAND ${CCACHE_FOUND} --get-config sloppiness OUTPUT_VARIABLE _CCACHE_SLOPPINESS OUTPUT_STRIP_TRAILING_WHITESPACE)
string (FIND "${_CCACHE_SLOPPINESS}" "pch_defines" _CCACHE_SLOPPINESS_RES)
if (NOT _CCACHE_SLOPPINESS_RES STREQUAL "-1")
string (FIND "${_CCACHE_SLOPPINESS}" "time_macros" _CCACHE_SLOPPINESS_RES)
endif ()

if (_CCACHE_SLOPPINESS_RES STREQUAL "-1")
message(WARNING "`Precompiled header` won't be cached by ccache, sloppiness = `${CCACHE_SLOPPINESS}`,please execute `ccache -o sloppiness=pch_defines,time_macros`")
set (ENABLE_PCH FALSE CACHE BOOL "" FORCE)
endif ()
endif ()

else ()
message (STATUS "Not using ccache ${CCACHE_FOUND}, USE_CCACHE=${USE_CCACHE}")
endif ()
33 changes: 33 additions & 0 deletions dbms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ add_headers_and_sources(dbms src/Storages/Page/V2/mvcc)
add_headers_and_sources(dbms src/Storages/Page/V2/VersionSet)
add_headers_and_sources(dbms src/Storages/Page/V2/gc)
add_headers_and_sources(dbms src/WindowFunctions)
add_headers_and_sources(dbms src/TiDB/Schema)
if (ENABLE_V3_PAGESTORAGE)
add_headers_and_sources(dbms src/Storages/Page/V3)
add_headers_and_sources(dbms src/Storages/Page/V3/LogFile)
Expand Down Expand Up @@ -258,6 +259,16 @@ target_include_directories (clickhouse_common_io BEFORE PRIVATE ${COMMON_INCLUDE
# https://cmake.org/pipermail/cmake/2016-May/063400.html
target_link_libraries (clickhouse_common_io PUBLIC ${TIFLASH_XXHASH_LIBRARY})

function(add_target_pch context target)
if (ENABLE_PCH)
message(STATUS "Add PCH `${context}` for target `${target}`")
target_precompile_headers(${target} PRIVATE ${context})
endif ()
if(${ARGC} GREATER 2)
add_target_pch(${context} ${ARGN})
endif()
endfunction()

if (ENABLE_TESTS)
include (${TiFlash_SOURCE_DIR}/cmake/find_gtest.cmake)

Expand Down Expand Up @@ -296,6 +307,8 @@ if (ENABLE_TESTS)
target_compile_options(gtests_dbms PRIVATE -Wno-unknown-pragmas -Wno-deprecated-copy)
add_check(gtests_dbms)

add_target_pch("pch-dbms.h" gtests_dbms)

grep_bench_sources(${TiFlash_SOURCE_DIR}/dbms dbms_bench_sources)
add_executable(bench_dbms EXCLUDE_FROM_ALL
${dbms_bench_sources}
Expand Down Expand Up @@ -341,3 +354,23 @@ if (TEST_COVERAGE AND CMAKE_BUILD_TYPE STREQUAL "Debug")
)
endif ()
endif ()

# dbms
add_target_pch("pch-dbms.h" dbms flash_service)
add_target_pch("pch-common.h" clickhouse_common_io clickhouse_functions clickhouse_aggregate_functions)
add_target_pch("pch-common.h" clickhouse_parsers clickhouse_storages_system dt-workload-lib clickhouse-server-lib)

# common
add_target_pch("pch-kvpb.h" kv_client)

add_target_pch("pch-stl.h" ${Boost_SYSTEM_LIBRARY} cctz ${RE2_LIBRARY} ${RE2_ST_LIBRARY})

# grpc
add_target_pch("$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/pch-stl.h>" grpc grpc++)

# pb
add_target_pch("pch-stl.h" libprotobuf kvproto tipb libprotoc)

# poco
add_target_pch("pch-stl.h" Net Crypto Util Data NetSSL)
add_target_pch("$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/pch-stl.h>" XML Foundation JSON)
23 changes: 23 additions & 0 deletions dbms/pch-common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2022 PingCAP, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <Common/Exception.h>
#include <Common/FmtUtils.h>
#include <Common/StackTrace.h>
#include <common/StringRef.h>
#include <common/types.h>

#include "pch-stl.h"
18 changes: 18 additions & 0 deletions dbms/pch-dbms.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2022 PingCAP, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include "pch-common.h"
#include "pch-kvpb.h"
26 changes: 26 additions & 0 deletions dbms/pch-kvpb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2022 PingCAP, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

/**
There may be unexpected behaviors for `ccache` to deal with PCH which includes those header files generated by tools:
'xxx' has been modified since the precompiled header 'xxx' was built: mtime changed
`Precompiled header includes xxx.h, which has a new mtime`
*/
#include <kvproto/enginepb.pb.h>
#include <kvproto/pdpb.grpc.pb.h>
#include <kvproto/tikvpb.grpc.pb.h>

#include "pch-stl.h"
34 changes: 34 additions & 0 deletions dbms/pch-stl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2022 PingCAP, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <algorithm>
#include <cassert>
#include <chrono>
#include <cstdint>
#include <fstream>
#include <functional>
#include <future>
#include <map>
#include <memory>
#include <mutex>
#include <ostream>
#include <queue>
#include <random>
#include <shared_mutex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
31 changes: 27 additions & 4 deletions dbms/src/Common/Decimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,6 @@ using Decimal64 = Decimal<Int64>;
using Decimal128 = Decimal<Int128>;
using Decimal256 = Decimal<Int256>;

static constexpr PrecType minDecimalPrecision()
{
return 1;
}
template <typename T>
static constexpr PrecType maxDecimalPrecision()
{
Expand All @@ -336,6 +332,33 @@ constexpr PrecType maxDecimalPrecision<Decimal256>()
return 65;
}

template <typename T>
constexpr PrecType minDecimalPrecision()
{
/// return a invalid value
return maxDecimalPrecision<Decimal256>() + 1;
}
template <>
constexpr PrecType minDecimalPrecision<Decimal32>()
{
return 1;
}
template <>
constexpr PrecType minDecimalPrecision<Decimal64>()
{
return maxDecimalPrecision<Decimal32>() + 1;
}
template <>
constexpr PrecType minDecimalPrecision<Decimal128>()
{
return maxDecimalPrecision<Decimal64>() + 1;
}
template <>
constexpr PrecType minDecimalPrecision<Decimal256>()
{
return maxDecimalPrecision<Decimal128>() + 1;
}

template <typename T>
struct PromoteType
{
Expand Down
3 changes: 2 additions & 1 deletion dbms/src/Common/FailPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ std::unordered_map<String, std::shared_ptr<FailPointChannel>> FailPointHelper::f
M(exception_when_read_from_log) \
M(exception_mpp_hash_build) \
M(exception_before_drop_segment) \
M(exception_after_drop_segment)
M(exception_after_drop_segment) \
M(exception_between_schema_change_in_the_same_diff)

#define APPLY_FOR_FAILPOINTS(M) \
M(skip_check_segment_update) \
Expand Down
10 changes: 4 additions & 6 deletions dbms/src/Common/FmtUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#pragma once

#include <common/StringRef.h>
#include <fmt/core.h>
#include <fmt/format.h>

namespace DB
Expand All @@ -32,9 +30,9 @@ class FmtBuffer
return *this;
}

FmtBuffer & append(StringRef s)
FmtBuffer & append(std::string_view s)
{
buffer.append(s.data, s.data + s.size);
buffer.append(s.data(), s.data() + s.size());
return *this;
}

Expand All @@ -55,7 +53,7 @@ class FmtBuffer
FmtBuffer & joinStr(
Iter first,
Iter end,
StringRef delimiter)
std::string_view delimiter)
{
auto func = [](const auto & s, FmtBuffer & fb) {
fb.append(s);
Expand All @@ -68,7 +66,7 @@ class FmtBuffer
Iter first,
Iter end,
FF && toStringFunc, // void (const auto &, FmtBuffer &)
StringRef delimiter)
std::string_view delimiter)
{
if (first == end)
return *this;
Expand Down
77 changes: 75 additions & 2 deletions dbms/src/Common/TiFlashException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,32 @@

namespace DB
{
struct TiFlashErrorRegistry::Errors : std::map<std::pair<std::string, std::string>, TiFlashError>
{
};

TiFlashErrorRegistry::Errors & TiFlashErrorRegistry::errors()
{
return *inner_data;
}

TiFlashErrorRegistry::Errors & TiFlashErrorRegistry::errors() const
{
return *inner_data;
}

TiFlashErrorRegistry::TiFlashErrorRegistry()
: inner_data(new Errors{})
{
initialize();
}

TiFlashErrorRegistry::~TiFlashErrorRegistry()
{
delete inner_data;
inner_data = nullptr;
}

void TiFlashErrorRegistry::initialize()
{
// Used to check uniqueness of classes
Expand Down Expand Up @@ -46,9 +72,9 @@ void TiFlashErrorRegistry::initialize()
void TiFlashErrorRegistry::registerError(const std::string & error_class, const std::string & error_code, const std::string & description, const std::string & workaround, const std::string & message_template)
{
TiFlashError error{error_class, error_code, description, workaround, message_template};
if (all_errors.find({error_class, error_code}) == all_errors.end())
if (errors().find({error_class, error_code}) == errors().end())
{
all_errors.emplace(std::make_pair(error_class, error_code), std::move(error));
errors().emplace(std::make_pair(error_class, error_code), std::move(error));
}
else
{
Expand Down Expand Up @@ -77,4 +103,51 @@ std::string TiFlashException::standardText() const
return text;
}

std::optional<TiFlashError> TiFlashErrorRegistry::get(const std::string & error_class, const std::string & error_code) const
{
auto error = errors().find({error_class, error_code});
if (error != errors().end())
{
return error->second;
}
else
{
return {};
}
}
std::optional<TiFlashError> TiFlashErrorRegistry::get(const std::string & error_class, int error_code) const
{
return get(error_class, std::to_string(error_code));
}

std::vector<TiFlashError> TiFlashErrorRegistry::allErrors() const
{
std::vector<TiFlashError> res;
res.reserve(errors().size());
for (const auto & error : errors())
{
res.push_back(error.second);
}
return res;
}

TiFlashError TiFlashErrorRegistry::simpleGet(const std::string & error_class, const std::string & error_code)
{
auto & m_instance = instance();
auto error = m_instance.get(error_class, error_code);
if (error.has_value())
{
return error.value();
}
else
{
throw Exception("Unregistered TiFlashError: FLASH:" + error_class + ":" + error_code);
}
}
TiFlashError TiFlashErrorRegistry::simpleGet(const std::string & error_class, int error_code)
{
return simpleGet(error_class, std::to_string(error_code));
}


} // namespace DB
Loading