From e9bac2d9a314b0c620bf0ff90461f8992b1b3174 Mon Sep 17 00:00:00 2001 From: Dog-Du <2976604925@qq.com> Date: Fri, 26 Jul 2024 11:56:10 +0800 Subject: [PATCH] load test --- CMakeLists.txt | 14 +++---- src/common/config.h | 2 +- src/execution/execution_manager.cpp | 59 ++++++++++++++++------------- 3 files changed, 41 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b14615c..971705e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,15 +13,15 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g") # #åˆ¤æ– -# if (${CMAKE_BUILD_TYPE} STREQUAL "Debug") -# add_definitions(-DDEBUG) -# endif () +if (${CMAKE_BUILD_TYPE} STREQUAL "Debug") + add_definitions(-DDEBUG) +endif () -# OPTION(CMAKE_EXPORT_COMPILE_COMMANDS ON) +OPTION(CMAKE_EXPORT_COMPILE_COMMANDS ON) -# ## æ£€æŸ¥å†…å˜æ³„æ¼æ²¡æœ‰ã€‚ -# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=undefined -fsanitize=leak") -# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined -fsanitize=leak") +## æ£€æŸ¥å†…å˜æ³„æ¼æ²¡æœ‰ã€‚ +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=undefined -fsanitize=leak") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined -fsanitize=leak") enable_testing() add_subdirectory(src) diff --git a/src/common/config.h b/src/common/config.h index a7dbfba..01be8e5 100755 --- a/src/common/config.h +++ b/src/common/config.h @@ -33,7 +33,7 @@ static constexpr int INVALID_TIMESTAMP = -1; // invalid transaction timestamp static constexpr int INVALID_LSN = -1; // invalid log sequence number static constexpr int HEADER_PAGE_ID = 0; // the header page id static constexpr int PAGE_SIZE = 4096; // size of a data page in byte 4KB -static constexpr int BUFFER_POOL_SIZE = 65536 * 4; // size of buffer pool 256MB +static constexpr int BUFFER_POOL_SIZE = 65536 * 6; // size of buffer pool 256MB // static constexpr int BUFFER_POOL_SIZE = 262144; // size of buffer // pool 1GB static constexpr int LOG_BUFFER_SIZE = (1024 * PAGE_SIZE); // size of a log buffer in byte diff --git a/src/execution/execution_manager.cpp b/src/execution/execution_manager.cpp index 871e7a1..d88e868 100755 --- a/src/execution/execution_manager.cpp +++ b/src/execution/execution_manager.cpp @@ -105,7 +105,6 @@ void QlManager::run_cmd_utility(std::shared_ptr<Plan> plan, txn_id_t *txn_id, Co case T_LoadTable: { static std::vector<std::thread> t; - static std::vector<std::thread> thread_ixs; auto f = [this](std::shared_ptr<OtherPlan> x) { auto disk_manager = sm_manager_->get_dm(); @@ -233,25 +232,41 @@ void QlManager::run_cmd_utility(std::shared_ptr<Plan> plan, txn_id_t *txn_id, Co thread_w(std::move(records)); } - auto thread_f = [](RmFileHandle *tab, TabMeta *tab_meta, - std::vector<IxIndexHandle *> *ixs) { - std::vector<RmRecord> ix_rcds; - for (auto &ix_meta : tab_meta->indexes) { - ix_rcds.push_back(RmRecord(ix_meta.col_tot_len)); - } - size_t i = 0; - for (RmScan scan(tab); !scan.is_end(); scan.next()) { - auto rcd = tab->get_record(scan.rid(), nullptr); - for (i = 0; i < ixs->size(); ++i) { - auto &ix = ixs->at(i); - auto &ix_rcd = ix_rcds[i]; - tab_meta->indexes[i].make_index_tuple(rcd.get(), &ix_rcd); - ix->insert_entry(ix_rcd.data, scan.rid(), nullptr); - } + // auto thread_f = [](RmFileHandle *tab, TabMeta *tab_meta, + // std::vector<IxIndexHandle *> *ixs) { + // std::vector<RmRecord> ix_rcds; + // for (auto &ix_meta : tab_meta->indexes) { + // ix_rcds.push_back(RmRecord(ix_meta.col_tot_len)); + // } + // size_t i = 0; + // for (RmScan scan(tab); !scan.is_end(); scan.next()) { + // auto rcd = tab->get_record(scan.rid(), nullptr); + // for (i = 0; i < ixs->size(); ++i) { + // auto &ix = ixs->at(i); + // auto &ix_rcd = ix_rcds[i]; + // tab_meta->indexes[i].make_index_tuple(rcd.get(), &ix_rcd); + // ix->insert_entry(ix_rcd.data, scan.rid(), nullptr); + // } + // } + // }; + + std::vector<RmRecord> ix_rcds; + for (auto &ix_meta : tab_meta.indexes) { + ix_rcds.push_back(RmRecord(ix_meta.col_tot_len)); + } + size_t i = 0; + for (RmScan scan(tab); !scan.is_end(); scan.next()) { + auto rcd = tab->get_record(scan.rid(), nullptr); + for (i = 0; i < ixs.size(); ++i) { + auto &ix = ixs.at(i); + auto &ix_rcd = ix_rcds[i]; + tab_meta.indexes[i].make_index_tuple(rcd.get(), &ix_rcd); + ix->insert_entry(ix_rcd.data, scan.rid(), nullptr); } - }; + } - thread_ixs.emplace_back(thread_f, tab, &tab_meta, &ixs); + // thread_ixs.emplace_back(thread_f, tab, &tab_meta, &ixs); + // sm_manager_->get_bpm()->flush_all_pages(); }; t.emplace_back(f, x); @@ -262,14 +277,6 @@ void QlManager::run_cmd_utility(std::shared_ptr<Plan> plan, txn_id_t *txn_id, Co } t.clear(); } - - if (thread_ixs.size() == 9) { - for (auto &i : thread_ixs ) { - i.join(); - } - sm_manager_->get_bpm()->flush_all_pages(); - } - } break; case T_CreateStaticCheckPoint: { -- GitLab