提交 a866c0c9 编写于 作者: O obdev 提交者: ob-robot

add system config (l1/l2/l3 cache size) to utility

上级 38f55496
......@@ -1940,5 +1940,54 @@ int is_dir_empty(const char *dirname, bool &is_empty)
return ret;
}
static int64_t get_cpu_cache_size(int sysconf_name, const char *sysfs_path, int64_t default_value)
{
int64_t cache_size = sysconf(sysconf_name);
if (OB_UNLIKELY(cache_size <= 0)) {
FILE *file = nullptr;
file = fopen(sysfs_path, "r");
if (file) {
fscanf(file, "%ld", &cache_size);
fclose(file);
cache_size *= 1024;
}
if (OB_UNLIKELY(nullptr == file || cache_size <= 0)) {
int ret = OB_ERR_UNEXPECTED;
COMMON_LOG(ERROR, "failed to read cpu cache size in file", KP(file), K(cache_size));
cache_size = default_value;
}
}
return cache_size;
}
int64_t get_level1_dcache_size()
{
const char *path = "/sys/devices/system/cpu/cpu0/cache/index0/size";
static int64_t l1_dcache_size = get_cpu_cache_size(_SC_LEVEL1_DCACHE_SIZE, path, 32768/*default L1 dcache size : 32K*/);
return l1_dcache_size;
}
int64_t get_level1_icache_size()
{
const char *path = "/sys/devices/system/cpu/cpu0/cache/index1/size";
static int64_t l1_icache_size = get_cpu_cache_size(_SC_LEVEL1_ICACHE_SIZE, path, 32768/*default L1 icache size : 32K*/);
return l1_icache_size;
}
int64_t get_level2_cache_size()
{
const char *path = "/sys/devices/system/cpu/cpu0/cache/index2/size";
static int64_t l2_cache_size = get_cpu_cache_size(_SC_LEVEL2_CACHE_SIZE, path, 524288/*default L2 cache size : 512K*/);
return l2_cache_size;
}
int64_t get_level3_cache_size()
{
const char *path = "/sys/devices/system/cpu/cpu0/cache/index3/size";
static int64_t l3_cache_size = get_cpu_cache_size(_SC_LEVEL3_CACHE_SIZE, path, 8388608/*default L3 cache size : 8192K*/);
return l3_cache_size;
}
} // end namespace common
} // end namespace oceanbase
......@@ -508,6 +508,14 @@ inline int64_t get_phy_mem_size()
return page_size * phys_pages;
}
int64_t get_level1_dcache_size();
int64_t get_level1_icache_size();
int64_t get_level2_cache_size();
int64_t get_level3_cache_size();
inline bool is_cpu_support_sse42()
{
#if defined (__x86_64__)
......
......@@ -21,8 +21,8 @@ namespace oceanbase
namespace sql
{
const int64_t INIT_L2_CACHE_SIZE = sysconf(_SC_LEVEL2_CACHE_SIZE);
const int64_t INIT_L3_CACHE_SIZE = sysconf(_SC_LEVEL3_CACHE_SIZE);
const int64_t INIT_L2_CACHE_SIZE = get_level2_cache_size();
const int64_t INIT_L3_CACHE_SIZE = get_level3_cache_size();
const int64_t MAX_L3_CACHE_SIZE = 50 *1024 *1024; //50M
const uint64_t FORCE_GPD = 0x100;
const int64_t MAX_REBUILD_TIMES = 5;
......
......@@ -21,6 +21,7 @@
#include "lib/container/ob_2d_array.h"
#include "sql/engine/aggregate/ob_exec_hash_struct.h"
#include "lib/lock/ob_scond.h"
#include "sql/engine/aggregate/ob_adaptive_bypass_ctrl.h"
namespace oceanbase
{
......@@ -1108,7 +1109,6 @@ private:
static const int64_t CACHE_AWARE_PART_CNT = 128;
static const int64_t BATCH_RESULT_SIZE = 512;
static const int64_t INIT_LTB_SIZE = 64;
static const int64_t INIT_L2_CACHE_SIZE = 1 * 1024 * 1024; // 1M
static const int64_t MIN_PART_COUNT = 8;
static const int64_t PAGE_SIZE = ObChunkDatumStore::BLOCK_SIZE;
static const int64_t MIN_MEM_SIZE = (MIN_PART_COUNT + 1) * PAGE_SIZE;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册