From 5603e7d1ebc0306f43ad060cf04f578ecb7195a8 Mon Sep 17 00:00:00 2001 From: hehechen Date: Fri, 17 Jun 2022 11:02:25 +0800 Subject: [PATCH 1/3] fix pageworklaod Signed-off-by: hehechen --- dbms/src/Storages/Page/workload/MainEntry.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/dbms/src/Storages/Page/workload/MainEntry.cpp b/dbms/src/Storages/Page/workload/MainEntry.cpp index ac82e1ea4bc..41c0f5045d1 100644 --- a/dbms/src/Storages/Page/workload/MainEntry.cpp +++ b/dbms/src/Storages/Page/workload/MainEntry.cpp @@ -24,31 +24,32 @@ int StressWorkload::mainEntry(int argc, char ** argv) // we do this to trigger REGISTER_WORKLOAD explicitly. void _work_load_register_named_HeavyMemoryCostInGC(); void (*f)() = _work_load_register_named_HeavyMemoryCostInGC; - (void)f; + f(); void _work_load_register_named_HeavyRead(); f = _work_load_register_named_HeavyRead; - (void)f; + f(); void _work_load_register_named_HeavySkewWriteRead(); f = _work_load_register_named_HeavySkewWriteRead; - (void)f; + f(); + ; void _work_load_register_named_HeavyWrite(); f = _work_load_register_named_HeavyWrite; - (void)f; + f(); void _work_load_register_named_HighValidBigFileGCWorkload(); f = _work_load_register_named_HighValidBigFileGCWorkload; - (void)f; + f(); void _work_load_register_named_HoldSnapshotsLongTime(); f = _work_load_register_named_HoldSnapshotsLongTime; - (void)f; + f(); void _work_load_register_named_PageStorageInMemoryCapacity(); f = _work_load_register_named_PageStorageInMemoryCapacity; - (void)f; + f(); void _work_load_register_named_NormalWorkload(); f = _work_load_register_named_NormalWorkload; - (void)f; + f(); void _work_load_register_named_ThousandsOfOffset(); f = _work_load_register_named_ThousandsOfOffset; - (void)f; + f(); } try { From e1e15ebcdfb39d7aa8b588b361a1c97c45eac3ee Mon Sep 17 00:00:00 2001 From: hehechen Date: Mon, 20 Jun 2022 15:29:42 +0800 Subject: [PATCH 2/3] fix comments Signed-off-by: hehechen --- dbms/src/Storages/Page/workload/MainEntry.cpp | 1 - dbms/src/Storages/Page/workload/PSWorkload.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dbms/src/Storages/Page/workload/MainEntry.cpp b/dbms/src/Storages/Page/workload/MainEntry.cpp index 41c0f5045d1..ba6bad9f7b8 100644 --- a/dbms/src/Storages/Page/workload/MainEntry.cpp +++ b/dbms/src/Storages/Page/workload/MainEntry.cpp @@ -31,7 +31,6 @@ int StressWorkload::mainEntry(int argc, char ** argv) void _work_load_register_named_HeavySkewWriteRead(); f = _work_load_register_named_HeavySkewWriteRead; f(); - ; void _work_load_register_named_HeavyWrite(); f = _work_load_register_named_HeavyWrite; f(); diff --git a/dbms/src/Storages/Page/workload/PSWorkload.h b/dbms/src/Storages/Page/workload/PSWorkload.h index eaaaf4eba5b..67c80ed9271 100644 --- a/dbms/src/Storages/Page/workload/PSWorkload.h +++ b/dbms/src/Storages/Page/workload/PSWorkload.h @@ -194,7 +194,7 @@ class StressWorkloadManger }; #define REGISTER_WORKLOAD(WORKLOAD) \ - void __attribute__((constructor)) _work_load_register_named_##WORKLOAD(void) \ + void _work_load_register_named_##WORKLOAD(void) \ { \ StressWorkloadManger::getInstance().reg( \ WORKLOAD::nameFunc(), \ From ea04f5f2233c25314c7812aa11ba0cd97dd05866 Mon Sep 17 00:00:00 2001 From: hehechen Date: Mon, 20 Jun 2022 16:19:41 +0800 Subject: [PATCH 3/3] use template function to register page stress workload Signed-off-by: hehechen --- .../src/Storages/Page/workload/CMakeLists.txt | 3 +- ...moryCostInGC.cpp => HeavyMemoryCostInGC.h} | 2 - .../workload/{HeavyRead.cpp => HeavyRead.h} | 2 - ...SkewWriteRead.cpp => HeavySkewWriteRead.h} | 2 - .../workload/{HeavyWrite.cpp => HeavyWrite.h} | 2 - ...alidBigFileGC.cpp => HighValidBigFileGC.h} | 2 - ...tsLongTime.cpp => HoldSnapshotsLongTime.h} | 2 - dbms/src/Storages/Page/workload/MainEntry.cpp | 48 +++++++------------ .../Page/workload/{Normal.cpp => Normal.h} | 2 - dbms/src/Storages/Page/workload/PSWorkload.h | 20 ++++---- ...city.cpp => PageStorageInMemoryCapacity.h} | 2 - ...usandsOfOffset.cpp => ThousandsOfOffset.h} | 2 - 12 files changed, 29 insertions(+), 60 deletions(-) rename dbms/src/Storages/Page/workload/{HeavyMemoryCostInGC.cpp => HeavyMemoryCostInGC.h} (98%) rename dbms/src/Storages/Page/workload/{HeavyRead.cpp => HeavyRead.h} (98%) rename dbms/src/Storages/Page/workload/{HeavySkewWriteRead.cpp => HeavySkewWriteRead.h} (98%) rename dbms/src/Storages/Page/workload/{HeavyWrite.cpp => HeavyWrite.h} (98%) rename dbms/src/Storages/Page/workload/{HighValidBigFileGC.cpp => HighValidBigFileGC.h} (98%) rename dbms/src/Storages/Page/workload/{HoldSnapshotsLongTime.cpp => HoldSnapshotsLongTime.h} (98%) rename dbms/src/Storages/Page/workload/{Normal.cpp => Normal.h} (98%) rename dbms/src/Storages/Page/workload/{PageStorageInMemoryCapacity.cpp => PageStorageInMemoryCapacity.h} (99%) rename dbms/src/Storages/Page/workload/{ThousandsOfOffset.cpp => ThousandsOfOffset.h} (99%) diff --git a/dbms/src/Storages/Page/workload/CMakeLists.txt b/dbms/src/Storages/Page/workload/CMakeLists.txt index 5c8ecb34d97..adf94c75f11 100644 --- a/dbms/src/Storages/Page/workload/CMakeLists.txt +++ b/dbms/src/Storages/Page/workload/CMakeLists.txt @@ -14,8 +14,7 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR}) -set (page-workload-src HeavyMemoryCostInGC.cpp HeavyRead.cpp HeavySkewWriteRead.cpp HeavyWrite.cpp HighValidBigFileGC.cpp HoldSnapshotsLongTime.cpp Normal.cpp - PageStorageInMemoryCapacity.cpp ThousandsOfOffset.cpp MainEntry.cpp Normal.cpp PageStorageInMemoryCapacity.cpp PSBackground.cpp PSRunnable.cpp PSStressEnv.cpp PSWorkload.cpp) +set (page-workload-src MainEntry.cpp PSBackground.cpp PSRunnable.cpp PSStressEnv.cpp PSWorkload.cpp) add_library (page-workload-lib ${page-workload-src}) target_link_libraries (page-workload-lib dbms clickhouse_functions clickhouse-server-lib) diff --git a/dbms/src/Storages/Page/workload/HeavyMemoryCostInGC.cpp b/dbms/src/Storages/Page/workload/HeavyMemoryCostInGC.h similarity index 98% rename from dbms/src/Storages/Page/workload/HeavyMemoryCostInGC.cpp rename to dbms/src/Storages/Page/workload/HeavyMemoryCostInGC.h index 7e745e29fc2..3daaf10ffb3 100644 --- a/dbms/src/Storages/Page/workload/HeavyMemoryCostInGC.cpp +++ b/dbms/src/Storages/Page/workload/HeavyMemoryCostInGC.h @@ -81,6 +81,4 @@ class HeavyMemoryCostInGC fmt::format("Memory Peak is {} , it should not bigger than {} ", metrics_dumper->getMemoryPeak(), 5 * 1024 * 1024)); } }; - -REGISTER_WORKLOAD(HeavyMemoryCostInGC) } // namespace DB::PS::tests diff --git a/dbms/src/Storages/Page/workload/HeavyRead.cpp b/dbms/src/Storages/Page/workload/HeavyRead.h similarity index 98% rename from dbms/src/Storages/Page/workload/HeavyRead.cpp rename to dbms/src/Storages/Page/workload/HeavyRead.h index a67c435e84c..80023f95988 100644 --- a/dbms/src/Storages/Page/workload/HeavyRead.cpp +++ b/dbms/src/Storages/Page/workload/HeavyRead.h @@ -70,6 +70,4 @@ class HeavyRead : public StressWorkload } } }; - -REGISTER_WORKLOAD(HeavyRead) } // namespace DB::PS::tests \ No newline at end of file diff --git a/dbms/src/Storages/Page/workload/HeavySkewWriteRead.cpp b/dbms/src/Storages/Page/workload/HeavySkewWriteRead.h similarity index 98% rename from dbms/src/Storages/Page/workload/HeavySkewWriteRead.cpp rename to dbms/src/Storages/Page/workload/HeavySkewWriteRead.h index 805bf105358..0e75bc0d3e5 100644 --- a/dbms/src/Storages/Page/workload/HeavySkewWriteRead.cpp +++ b/dbms/src/Storages/Page/workload/HeavySkewWriteRead.h @@ -85,6 +85,4 @@ class HeavySkewWriteRead : public StressWorkload return true; } }; - -REGISTER_WORKLOAD(HeavySkewWriteRead) } // namespace DB::PS::tests \ No newline at end of file diff --git a/dbms/src/Storages/Page/workload/HeavyWrite.cpp b/dbms/src/Storages/Page/workload/HeavyWrite.h similarity index 98% rename from dbms/src/Storages/Page/workload/HeavyWrite.cpp rename to dbms/src/Storages/Page/workload/HeavyWrite.h index 8dfd7f810f7..54b7585ee20 100644 --- a/dbms/src/Storages/Page/workload/HeavyWrite.cpp +++ b/dbms/src/Storages/Page/workload/HeavyWrite.h @@ -72,6 +72,4 @@ class HeavyWrite : public StressWorkload return true; } }; - -REGISTER_WORKLOAD(HeavyWrite) } // namespace DB::PS::tests \ No newline at end of file diff --git a/dbms/src/Storages/Page/workload/HighValidBigFileGC.cpp b/dbms/src/Storages/Page/workload/HighValidBigFileGC.h similarity index 98% rename from dbms/src/Storages/Page/workload/HighValidBigFileGC.cpp rename to dbms/src/Storages/Page/workload/HighValidBigFileGC.h index a9af6aebb76..cc3b5b45135 100644 --- a/dbms/src/Storages/Page/workload/HighValidBigFileGC.cpp +++ b/dbms/src/Storages/Page/workload/HighValidBigFileGC.h @@ -129,6 +129,4 @@ class HighValidBigFileGCWorkload private: UInt64 gc_time_ms = 0; }; - -REGISTER_WORKLOAD(HighValidBigFileGCWorkload) } // namespace DB::PS::tests \ No newline at end of file diff --git a/dbms/src/Storages/Page/workload/HoldSnapshotsLongTime.cpp b/dbms/src/Storages/Page/workload/HoldSnapshotsLongTime.h similarity index 98% rename from dbms/src/Storages/Page/workload/HoldSnapshotsLongTime.cpp rename to dbms/src/Storages/Page/workload/HoldSnapshotsLongTime.h index f02fbf65bcd..071a104010c 100644 --- a/dbms/src/Storages/Page/workload/HoldSnapshotsLongTime.cpp +++ b/dbms/src/Storages/Page/workload/HoldSnapshotsLongTime.h @@ -94,6 +94,4 @@ class HoldSnapshotsLongTime : public StressWorkload return true; } }; - -REGISTER_WORKLOAD(HoldSnapshotsLongTime) } // namespace DB::PS::tests \ No newline at end of file diff --git a/dbms/src/Storages/Page/workload/MainEntry.cpp b/dbms/src/Storages/Page/workload/MainEntry.cpp index ba6bad9f7b8..18e42106c90 100644 --- a/dbms/src/Storages/Page/workload/MainEntry.cpp +++ b/dbms/src/Storages/Page/workload/MainEntry.cpp @@ -11,44 +11,32 @@ // 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. +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include using namespace DB::PS::tests; int StressWorkload::mainEntry(int argc, char ** argv) { { - // maybe due to sequence of linking, REGISTER_WORKLOAD is not visible to main function in dbms/src/Server/main.cpp - // cause that REGISTER_WORKLOAD will not be triggered before mainEntry - // we do this to trigger REGISTER_WORKLOAD explicitly. - void _work_load_register_named_HeavyMemoryCostInGC(); - void (*f)() = _work_load_register_named_HeavyMemoryCostInGC; - f(); - void _work_load_register_named_HeavyRead(); - f = _work_load_register_named_HeavyRead; - f(); - void _work_load_register_named_HeavySkewWriteRead(); - f = _work_load_register_named_HeavySkewWriteRead; - f(); - void _work_load_register_named_HeavyWrite(); - f = _work_load_register_named_HeavyWrite; - f(); - void _work_load_register_named_HighValidBigFileGCWorkload(); - f = _work_load_register_named_HighValidBigFileGCWorkload; - f(); - void _work_load_register_named_HoldSnapshotsLongTime(); - f = _work_load_register_named_HoldSnapshotsLongTime; - f(); - void _work_load_register_named_PageStorageInMemoryCapacity(); - f = _work_load_register_named_PageStorageInMemoryCapacity; - f(); - void _work_load_register_named_NormalWorkload(); - f = _work_load_register_named_NormalWorkload; - f(); - void _work_load_register_named_ThousandsOfOffset(); - f = _work_load_register_named_ThousandsOfOffset; - f(); + work_load_register(); + work_load_register(); + work_load_register(); + work_load_register(); + work_load_register(); + work_load_register(); + work_load_register(); + work_load_register(); + work_load_register(); } try { diff --git a/dbms/src/Storages/Page/workload/Normal.cpp b/dbms/src/Storages/Page/workload/Normal.h similarity index 98% rename from dbms/src/Storages/Page/workload/Normal.cpp rename to dbms/src/Storages/Page/workload/Normal.h index 57229395809..164f17b9d61 100644 --- a/dbms/src/Storages/Page/workload/Normal.cpp +++ b/dbms/src/Storages/Page/workload/Normal.h @@ -77,6 +77,4 @@ class NormalWorkload stop_watch.stop(); } }; - -REGISTER_WORKLOAD(NormalWorkload) } // namespace DB::PS::tests diff --git a/dbms/src/Storages/Page/workload/PSWorkload.h b/dbms/src/Storages/Page/workload/PSWorkload.h index 67c80ed9271..26a9c24d6da 100644 --- a/dbms/src/Storages/Page/workload/PSWorkload.h +++ b/dbms/src/Storages/Page/workload/PSWorkload.h @@ -193,15 +193,15 @@ class StressWorkloadManger StressEnv options; }; -#define REGISTER_WORKLOAD(WORKLOAD) \ - void _work_load_register_named_##WORKLOAD(void) \ - { \ - StressWorkloadManger::getInstance().reg( \ - WORKLOAD::nameFunc(), \ - WORKLOAD::maskFunc(), \ - [](const StressEnv & opts) -> std::shared_ptr { \ - return std::make_shared(opts); \ - }); \ - } +template +void work_load_register() +{ + StressWorkloadManger::getInstance().reg( + Workload::nameFunc(), + Workload::maskFunc(), + [](const StressEnv & opts) -> std::shared_ptr { + return std::make_shared(opts); + }); +} } // namespace DB::PS::tests diff --git a/dbms/src/Storages/Page/workload/PageStorageInMemoryCapacity.cpp b/dbms/src/Storages/Page/workload/PageStorageInMemoryCapacity.h similarity index 99% rename from dbms/src/Storages/Page/workload/PageStorageInMemoryCapacity.cpp rename to dbms/src/Storages/Page/workload/PageStorageInMemoryCapacity.h index 6ab321d1a10..337c732e6f7 100644 --- a/dbms/src/Storages/Page/workload/PageStorageInMemoryCapacity.cpp +++ b/dbms/src/Storages/Page/workload/PageStorageInMemoryCapacity.h @@ -174,6 +174,4 @@ class PageStorageInMemoryCapacity : public StressWorkload std::round(resident_used) ? (total_mem / ((double)resident_used / page_writen)) : 0)); } }; - -REGISTER_WORKLOAD(PageStorageInMemoryCapacity) } // namespace DB::PS::tests \ No newline at end of file diff --git a/dbms/src/Storages/Page/workload/ThousandsOfOffset.cpp b/dbms/src/Storages/Page/workload/ThousandsOfOffset.h similarity index 99% rename from dbms/src/Storages/Page/workload/ThousandsOfOffset.cpp rename to dbms/src/Storages/Page/workload/ThousandsOfOffset.h index 5a02ef48d68..0232ea235f1 100644 --- a/dbms/src/Storages/Page/workload/ThousandsOfOffset.cpp +++ b/dbms/src/Storages/Page/workload/ThousandsOfOffset.h @@ -169,6 +169,4 @@ class ThousandsOfOffset : public StressWorkload return true; } }; - -REGISTER_WORKLOAD(ThousandsOfOffset) } // namespace DB::PS::tests \ No newline at end of file