From 8a81342c104a78c9d84b2877c111a4cb87e3cdff Mon Sep 17 00:00:00 2001 From: Lloyd-Pottiger <60744015+Lloyd-Pottiger@users.noreply.github.com> Date: Fri, 10 Jun 2022 21:42:30 +0800 Subject: [PATCH] add some notes about `getMemoryAmount()` and `getNumberOfPhysicalCPUCores()` (#5126) close pingcap/tiflash#5125 --- dbms/src/Common/getNumberOfPhysicalCPUCores.h | 1 + dbms/src/Storages/DeltaMerge/workload/Handle.h | 6 ++++-- libs/libcommon/include/common/getMemoryAmount.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dbms/src/Common/getNumberOfPhysicalCPUCores.h b/dbms/src/Common/getNumberOfPhysicalCPUCores.h index 6f7eaef4bb4..b3ab65a66e5 100644 --- a/dbms/src/Common/getNumberOfPhysicalCPUCores.h +++ b/dbms/src/Common/getNumberOfPhysicalCPUCores.h @@ -15,4 +15,5 @@ #pragma once /// Get number of CPU cores without hyper-threading. +/// Note: do not support environment under resource isolation mechanism like Docker, CGroup. unsigned getNumberOfPhysicalCPUCores(); diff --git a/dbms/src/Storages/DeltaMerge/workload/Handle.h b/dbms/src/Storages/DeltaMerge/workload/Handle.h index c4949c15a1f..2bbd1bd409d 100644 --- a/dbms/src/Storages/DeltaMerge/workload/Handle.h +++ b/dbms/src/Storages/DeltaMerge/workload/Handle.h @@ -51,14 +51,16 @@ class HandleLock std::vector> getLocks(const std::vector & handles) { - std::vector indexes(handles.size()); + std::vector indexes; + indexes.reserve(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> locks(indexes.size()); + std::vector> locks; + locks.reserve(indexes.size()); for (auto i : indexes) { locks.push_back(getLockByIndex(i)); diff --git a/libs/libcommon/include/common/getMemoryAmount.h b/libs/libcommon/include/common/getMemoryAmount.h index 98aa87661c3..0807c6f8e12 100644 --- a/libs/libcommon/include/common/getMemoryAmount.h +++ b/libs/libcommon/include/common/getMemoryAmount.h @@ -19,5 +19,6 @@ /** * Returns the size of physical memory (RAM) in bytes. * Returns 0 on unsupported platform +* Note: do not support environment under resource isolation mechanism like Docker, CGroup. */ uint64_t getMemoryAmount();