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

feat: add page_stress_testing as a subcommand of tiflash #5038

Merged
merged 23 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5f8096d
move stree workload under namespace DB::PS::tests
Lloyd-Pottiger May 31, 2022
e7cf388
fix clang-tidy error
Lloyd-Pottiger May 31, 2022
75c0c86
fix clang-tidy error
Lloyd-Pottiger May 31, 2022
d3be4aa
add mainEntry.cpp
Lloyd-Pottiger May 31, 2022
5a36b3f
change directory layout and add CMakeLists.txt
Lloyd-Pottiger May 31, 2022
8ba638c
add it to main.cpp
Lloyd-Pottiger May 31, 2022
f266aaa
fix some known errors
Lloyd-Pottiger Jun 1, 2022
79e1dee
remove page_storage_v3 in workload CMakeLists
Lloyd-Pottiger Jun 1, 2022
e80288d
explicit trigger REGISTER_WORKLOAD
Lloyd-Pottiger Jun 1, 2022
3a3f46a
fix tidy error
Lloyd-Pottiger Jun 1, 2022
28cc416
fix tidy error
Lloyd-Pottiger Jun 1, 2022
9124d5d
change CMakeLists
Lloyd-Pottiger Jun 1, 2022
cb478ef
add some comments about trigger register
Lloyd-Pottiger Jun 2, 2022
9473123
Merge branch 'master' into add-page-stress-as-a-command
Lloyd-Pottiger Jun 2, 2022
5e5e06c
reslove conflicts
Lloyd-Pottiger Jun 2, 2022
c406056
rename stressworkload to pageworkload
Lloyd-Pottiger Jun 7, 2022
09c139c
rollback irrelevant changes
Lloyd-Pottiger Jun 7, 2022
201ddbf
remove ENABLE_V3_PAGESTORAGE
Lloyd-Pottiger Jun 9, 2022
5f8afb2
remove dt-workload & page-workload executable target
Lloyd-Pottiger Jun 9, 2022
fdee8de
remove useless code
Lloyd-Pottiger Jun 9, 2022
5394c4b
remove stress & tools dir
Lloyd-Pottiger Jun 9, 2022
247ae77
clear clang-tidy error
Lloyd-Pottiger Jun 9, 2022
88fb2d6
Merge branch 'master' into add-page-stress-as-a-command
ti-chi-bot Jun 10, 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
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,6 @@ else (ENABLE_FAILPOINTS)
message (STATUS "Failpoints are disabled")
endif (ENABLE_FAILPOINTS)

# Enable PageStorage V3 test.
option (ENABLE_V3_PAGESTORAGE "Enables V3 PageStorage" ON)

# Flags for test coverage
option (TEST_COVERAGE "Enables flags for test coverage" OFF)
option (TEST_COVERAGE_XML "Output XML report for test coverage" OFF)
Expand Down
13 changes: 7 additions & 6 deletions dbms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,10 @@ 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)
add_headers_and_sources(dbms src/Storages/Page/V3/WAL)
add_headers_and_sources(dbms src/Storages/Page/V3/spacemap)
endif()
add_headers_and_sources(dbms src/Storages/Page/V3)
add_headers_and_sources(dbms src/Storages/Page/V3/LogFile)
add_headers_and_sources(dbms src/Storages/Page/V3/WAL)
add_headers_and_sources(dbms src/Storages/Page/V3/spacemap)
add_headers_and_sources(dbms src/Storages/Page/)
add_headers_and_sources(dbms src/TiDB)
add_headers_and_sources(dbms src/Client)
Expand Down Expand Up @@ -311,6 +309,9 @@ if (ENABLE_TESTS)
if (ENABLE_TIFLASH_DTWORKLOAD)
target_link_libraries(bench_dbms dt-workload-lib)
endif ()
if (ENABLE_TIFLASH_PAGEWORKLOAD)
target_link_libraries(bench_dbms page-workload-lib)
endif ()

add_check(bench_dbms)
endif ()
Expand Down
4 changes: 4 additions & 0 deletions dbms/src/Server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ option(ENABLE_CLICKHOUSE_SERVER "Enable server" ${ENABLE_CLICKHOUSE_ALL})
option(ENABLE_CLICKHOUSE_CLIENT "Enable client" ${ENABLE_CLICKHOUSE_ALL})
option(ENABLE_TIFLASH_DTTOOL "Enable dttool: tools to manage dmfile" ${ENABLE_CLICKHOUSE_ALL})
option(ENABLE_TIFLASH_DTWORKLOAD "Enable dtworkload: tools to test and stress DeltaTree" ${ENABLE_CLICKHOUSE_ALL})
option(ENABLE_TIFLASH_PAGEWORKLOAD "Enable pageworkload: tools to test and stress PageStorage" ${ENABLE_CLICKHOUSE_ALL})
option(ENABLE_TIFLASH_PAGECTL "Enable pagectl: tools to debug page storage" ${ENABLE_CLICKHOUSE_ALL})

configure_file (config_tools.h.in ${CMAKE_CURRENT_BINARY_DIR}/config_tools.h)
Expand Down Expand Up @@ -136,6 +137,9 @@ endif ()
if (ENABLE_TIFLASH_DTWORKLOAD)
target_link_libraries(tiflash dt-workload-lib)
endif ()
if (ENABLE_TIFLASH_PAGEWORKLOAD)
target_link_libraries(tiflash page-workload-lib)
endif()
if (ENABLE_TIFLASH_PAGECTL)
target_link_libraries(tiflash page-ctl-lib)
endif ()
Expand Down
1 change: 1 addition & 0 deletions dbms/src/Server/config_tools.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
#cmakedefine01 ENABLE_CLICKHOUSE_CLIENT
#cmakedefine01 ENABLE_TIFLASH_DTTOOL
#cmakedefine01 ENABLE_TIFLASH_DTWORKLOAD
#cmakedefine01 ENABLE_TIFLASH_PAGEWORKLOAD
#cmakedefine01 ENABLE_TIFLASH_PAGECTL
8 changes: 7 additions & 1 deletion dbms/src/Server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
#include <Server/DTTool/DTTool.h>
#endif
#if ENABLE_TIFLASH_DTWORKLOAD
#include <Storages/DeltaMerge/tools/workload/DTWorkload.h>
#include <Storages/DeltaMerge/workload/DTWorkload.h>
#endif
#if ENABLE_TIFLASH_PAGEWORKLOAD
#include <Storages/Page/workload/PSWorkload.h>
#endif
#if ENABLE_TIFLASH_PAGECTL
#include <Storages/Page/tools/PageCtl/PageStorageCtl.h>
Expand Down Expand Up @@ -107,6 +110,9 @@ std::pair<const char *, MainFunc> clickhouse_applications[] = {
#if ENABLE_TIFLASH_DTWORKLOAD
{"dtworkload", DB::DM::tests::DTWorkload::mainEntry},
#endif
#if ENABLE_TIFLASH_PAGEWORKLOAD
{"pageworkload", DB::PS::tests::StressWorkload::mainEntry},
#endif
#if ENABLE_TIFLASH_PAGECTL
{"pagectl", DB::PageStorageCtl::mainEntry},
#endif
Expand Down
9 changes: 4 additions & 5 deletions dbms/src/Storages/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
add_subdirectory (System)
add_subdirectory (Page)
add_subdirectory (DeltaMerge/File/dtpb)
add_subdirectory (DeltaMerge/tools)
add_subdirectory (DeltaMerge/workload)
add_subdirectory (Page/workload)

if (ENABLE_TESTS)
add_subdirectory (tests EXCLUDE_FROM_ALL)
add_subdirectory (Transaction/tests EXCLUDE_FROM_ALL)
add_subdirectory (Page/V2/tests EXCLUDE_FROM_ALL)
if (ENABLE_V3_PAGESTORAGE)
add_subdirectory (Page/V3 EXCLUDE_FROM_ALL)
add_subdirectory (Page/V3/tests EXCLUDE_FROM_ALL)
endif ()
add_subdirectory (Page/V3 EXCLUDE_FROM_ALL)
add_subdirectory (Page/V3/tests EXCLUDE_FROM_ALL)
add_subdirectory (DeltaMerge/tests EXCLUDE_FROM_ALL)
endif ()

22 changes: 0 additions & 22 deletions dbms/src/Storages/DeltaMerge/tools/workload/Main.cpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,3 @@ set(dt-workload-src MainEntry.cpp DTWorkload.cpp KeyGenerator.cpp TableGenerator

add_library(dt-workload-lib ${dt-workload-src})
target_link_libraries(dt-workload-lib dbms clickhouse_functions clickhouse-server-lib)

add_executable(dt-workload Main.cpp ${dt-workload-src})
target_link_libraries(dt-workload dbms gtest clickhouse_functions clickhouse-server-lib)
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
#include <Poco/Util/LayeredConfiguration.h>
#include <Storages/DeltaMerge/DeltaMergeStore.h>
#include <Storages/DeltaMerge/Filter/RSOperator.h>
#include <Storages/DeltaMerge/tools/workload/DTWorkload.h>
#include <Storages/DeltaMerge/tools/workload/DataGenerator.h>
#include <Storages/DeltaMerge/tools/workload/Handle.h>
#include <Storages/DeltaMerge/tools/workload/KeyGenerator.h>
#include <Storages/DeltaMerge/tools/workload/Limiter.h>
#include <Storages/DeltaMerge/tools/workload/Options.h>
#include <Storages/DeltaMerge/tools/workload/ReadColumnsGenerator.h>
#include <Storages/DeltaMerge/tools/workload/TableGenerator.h>
#include <Storages/DeltaMerge/tools/workload/TimestampGenerator.h>
#include <Storages/DeltaMerge/tools/workload/Utils.h>
#include <Storages/DeltaMerge/workload/DTWorkload.h>
#include <Storages/DeltaMerge/workload/DataGenerator.h>
#include <Storages/DeltaMerge/workload/Handle.h>
#include <Storages/DeltaMerge/workload/KeyGenerator.h>
#include <Storages/DeltaMerge/workload/Limiter.h>
#include <Storages/DeltaMerge/workload/Options.h>
#include <Storages/DeltaMerge/workload/ReadColumnsGenerator.h>
#include <Storages/DeltaMerge/workload/TableGenerator.h>
#include <Storages/DeltaMerge/workload/TimestampGenerator.h>
#include <Storages/DeltaMerge/workload/Utils.h>
#include <TestUtils/TiFlashTestEnv.h>
#include <cpptoml.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ThreadStat
class Statistics
{
public:
Statistics(int write_thread_count = 0, int read_thread_count = 0)
explicit Statistics(int write_thread_count = 0, int read_thread_count = 0)
: init_ms(0)
, write_stats(write_thread_count)
, read_stats(read_thread_count)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
// limitations under the License.

#include <DataTypes/DataTypeEnum.h>
#include <Storages/DeltaMerge/tools/workload/DataGenerator.h>
#include <Storages/DeltaMerge/tools/workload/KeyGenerator.h>
#include <Storages/DeltaMerge/tools/workload/Options.h>
#include <Storages/DeltaMerge/tools/workload/TableGenerator.h>
#include <Storages/DeltaMerge/tools/workload/TimestampGenerator.h>
#include <Storages/DeltaMerge/workload/DataGenerator.h>
#include <Storages/DeltaMerge/workload/KeyGenerator.h>
#include <Storages/DeltaMerge/workload/Options.h>
#include <Storages/DeltaMerge/workload/TableGenerator.h>
#include <Storages/DeltaMerge/workload/TimestampGenerator.h>
#include <fmt/ranges.h>

#include <random>
Expand All @@ -33,7 +33,7 @@ class RandomDataGenerator : public DataGenerator
, rand_gen(std::random_device()())
{}

virtual std::tuple<Block, uint64_t> get(uint64_t key) override
std::tuple<Block, uint64_t> get(uint64_t key) override
{
Block block;
// Generate 'rowkeys'.
Expand Down Expand Up @@ -227,7 +227,9 @@ class RandomDataGenerator : public DataGenerator
struct tm randomLocalTime()
{
time_t t = randomUTCTimestamp();
struct tm res;
struct tm res
{
};
if (localtime_r(&t, &res) == nullptr)
{
throw std::invalid_argument(fmt::format("localtime_r({}) ret {}", t, strerror(errno)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DataGenerator
public:
static std::unique_ptr<DataGenerator> create(const WorkloadOptions & opts, const TableInfo & table_info, TimestampGenerator & ts_gen);
virtual std::tuple<Block, uint64_t> get(uint64_t key) = 0;
virtual ~DataGenerator() {}
virtual ~DataGenerator() = default;
};

std::string blockToString(const Block & block);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <Encryption/PosixRandomAccessFile.h>
#include <Encryption/PosixWritableFile.h>
#include <Storages/DeltaMerge/tools/workload/TableGenerator.h>
#include <Storages/DeltaMerge/workload/TableGenerator.h>
#include <fcntl.h>

#include <memory>
Expand All @@ -40,7 +40,7 @@ class HandleLock
static constexpr uint64_t default_lock_count = 4096;

static std::unique_ptr<HandleLock> create(const TableInfo & table_info);
HandleLock(uint64_t lock_count = default_lock_count)
explicit HandleLock(uint64_t lock_count = default_lock_count)
: rmtxs(lock_count)
{}

Expand All @@ -51,14 +51,14 @@ class HandleLock

std::vector<std::unique_lock<std::recursive_mutex>> getLocks(const std::vector<uint64_t> & handles)
{
std::vector<uint64_t> indexes;
std::vector<uint64_t> indexes(handles.size());
for (const auto & h : handles)
{
indexes.push_back(index(h));
}
// Sort mutex indexes to avoid dead lock.
sort(indexes.begin(), indexes.end());
std::vector<std::unique_lock<std::recursive_mutex>> locks;
std::vector<std::unique_lock<std::recursive_mutex>> locks(indexes.size());
for (auto i : indexes)
{
locks.push_back(getLockByIndex(i));
Expand Down Expand Up @@ -105,7 +105,7 @@ class HandleTable
std::lock_guard lock(mtx);
handle_to_ts[handle] = ts;
Record r{handle, ts};
if (wal != nullptr && wal->write((char *)&r, sizeof(r)) != sizeof(r))
if (wal != nullptr && wal->write(reinterpret_cast<char *>(&r), sizeof(r)) != sizeof(r))
{
throw std::runtime_error(fmt::format("write ret {}", strerror(errno)));
}
Expand Down Expand Up @@ -134,8 +134,8 @@ class HandleTable
try
{
PosixRandomAccessFile f(fname, -1);
Record r;
while (f.read((char *)&r, sizeof(r)) == sizeof(r))
Record r{};
while (f.read(reinterpret_cast<char *>(&r), sizeof(r)) == sizeof(r))
{
handle_to_ts[r.handle] = r.ts;
}
Expand All @@ -156,7 +156,7 @@ class HandleTable
for (const auto & pa : handle_to_ts)
{
Record r{pa.first, pa.second};
if (f.write((char *)&r, sizeof(r)) != sizeof(r))
if (f.write(reinterpret_cast<char *>(&r), sizeof(r)) != sizeof(r))
{
throw std::runtime_error(fmt::format("write ret {}", strerror(errno)));
}
Expand Down Expand Up @@ -191,7 +191,7 @@ class SharedHandleTable
public:
static constexpr uint64_t default_shared_count = 4096;

SharedHandleTable(uint64_t max_key_count, const std::string & waldir = "", uint64_t shared_cnt = default_shared_count)
explicit SharedHandleTable(uint64_t max_key_count, const std::string & waldir = "", uint64_t shared_cnt = default_shared_count)
: tables(shared_cnt)
{
uint64_t max_key_count_per_shared = max_key_count / default_shared_count + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <Storages/DeltaMerge/tools/workload/KeyGenerator.h>
#include <Storages/DeltaMerge/tools/workload/Options.h>
#include <Storages/DeltaMerge/workload/KeyGenerator.h>
#include <Storages/DeltaMerge/workload/Options.h>
#include <fmt/core.h>

#include <atomic>
Expand All @@ -31,7 +31,7 @@ class IncrementalKeyGenerator : public KeyGenerator
, key(0)
{}

virtual uint64_t get64() override
uint64_t get64() override
{
return key.fetch_add(1, std::memory_order_relaxed) % key_count + start_key;
}
Expand All @@ -54,7 +54,7 @@ class UniformDistributionKeyGenerator : public KeyGenerator
, uniform_dist(0, key_count)
{}

virtual uint64_t get64() override
uint64_t get64() override
{
std::lock_guard lock(mtx);
return uniform_dist(rand_gen);
Expand All @@ -78,7 +78,7 @@ class NormalDistributionKeyGenerator : public KeyGenerator
, normal_dist(key_count / 2.0, key_count / 20.0)
{}

virtual uint64_t get64() override
uint64_t get64() override
{
std::lock_guard lock(mtx);
return normal_dist(rand_gen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class KeyGenerator
public:
static std::unique_ptr<KeyGenerator> create(const WorkloadOptions & opts);

KeyGenerator() {}
virtual ~KeyGenerator() {}
KeyGenerator() = default;
virtual ~KeyGenerator() = default;

virtual uint64_t get64() = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.

#include <Encryption/RateLimiter.h>
#include <Storages/DeltaMerge/tools/workload/Limiter.h>
#include <Storages/DeltaMerge/tools/workload/Options.h>
#include <Storages/DeltaMerge/workload/Limiter.h>
#include <Storages/DeltaMerge/workload/Options.h>
#include <fmt/core.h>

#include <cmath>
Expand All @@ -24,10 +24,10 @@ namespace DB::DM::tests
class ConstantLimiter : public Limiter
{
public:
ConstantLimiter(uint64_t rate_per_sec)
explicit ConstantLimiter(uint64_t rate_per_sec)
: limiter(rate_per_sec, LimiterType::UNKNOW)
{}
virtual void request() override
void request() override
{
limiter.request(1);
}
Expand All @@ -38,7 +38,7 @@ class ConstantLimiter : public Limiter

std::unique_ptr<Limiter> Limiter::create(const WorkloadOptions & opts)
{
uint64_t per_sec = std::ceil(static_cast<double>(opts.max_write_per_sec / opts.write_thread_count));
uint64_t per_sec = std::ceil(opts.max_write_per_sec * 1.0 / opts.write_thread_count);
return std::make_unique<ConstantLimiter>(per_sec);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ class Limiter
public:
static std::unique_ptr<Limiter> create(const WorkloadOptions & opts);
virtual void request() = 0;
virtual ~Limiter() {}
virtual ~Limiter() = default;
};
} // namespace DB::DM::tests
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

#include <Common/Exception.h>
#include <Common/Logger.h>
#include <Storages/DeltaMerge/tools/workload/DTWorkload.h>
#include <Storages/DeltaMerge/tools/workload/Handle.h>
#include <Storages/DeltaMerge/tools/workload/Options.h>
#include <Storages/DeltaMerge/tools/workload/Utils.h>
#include <Storages/DeltaMerge/workload/DTWorkload.h>
#include <Storages/DeltaMerge/workload/Handle.h>
#include <Storages/DeltaMerge/workload/Options.h>
#include <Storages/DeltaMerge/workload/Utils.h>
#include <Storages/PathPool.h>
#include <TestUtils/TiFlashTestEnv.h>
#include <common/logger_useful.h>
Expand Down
Loading