Skip to content

Commit

Permalink
add some notes about getMemoryAmount() and `getNumberOfPhysicalCPUC…
Browse files Browse the repository at this point in the history
…ores()` (#5126)

close #5125
  • Loading branch information
Lloyd-Pottiger authored Jun 10, 2022
1 parent 8916afe commit 8a81342
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions dbms/src/Common/getNumberOfPhysicalCPUCores.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
6 changes: 4 additions & 2 deletions dbms/src/Storages/DeltaMerge/workload/Handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ class HandleLock

std::vector<std::unique_lock<std::recursive_mutex>> getLocks(const std::vector<uint64_t> & handles)
{
std::vector<uint64_t> indexes(handles.size());
std::vector<uint64_t> 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<std::unique_lock<std::recursive_mutex>> locks(indexes.size());
std::vector<std::unique_lock<std::recursive_mutex>> locks;
locks.reserve(indexes.size());
for (auto i : indexes)
{
locks.push_back(getLockByIndex(i));
Expand Down
1 change: 1 addition & 0 deletions libs/libcommon/include/common/getMemoryAmount.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

0 comments on commit 8a81342

Please sign in to comment.