Skip to content

Commit

Permalink
[improvement](segmentcache) limit segment cache by fd limit or memory
Browse files Browse the repository at this point in the history
remove a useless config.
  • Loading branch information
dataroaring committed Aug 20, 2024
1 parent 5280c18 commit 0a17104
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
7 changes: 4 additions & 3 deletions be/src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "common/config.h"
#include "common/logging.h"
#include "common/status.h"
#include "config.h"
#include "io/fs/file_writer.h"
#include "io/fs/local_file_system.h"
#include "util/cpu_info.h"
Expand Down Expand Up @@ -1067,10 +1068,10 @@ DEFINE_mInt32(schema_cache_capacity, "1024");
DEFINE_mInt32(schema_cache_sweep_time_sec, "100");

// max number of segment cache, default -1 for backward compatibility fd_number*2/5
DEFINE_mInt32(segment_cache_capacity, "-1");
DEFINE_mInt32(estimated_num_columns_per_segment, "200");
DEFINE_Int32(segment_cache_capacity, "-1");
DEFINE_Int32(segment_cache_fd_percentage, "40");
DEFINE_mInt32(estimated_mem_per_column_reader, "1024");
DEFINE_mInt32(segment_cache_memory_percentage, "2");
DEFINE_Int32(segment_cache_memory_percentage, "2");

// enable feature binlog, default false
DEFINE_Bool(enable_feature_binlog, "false");
Expand Down
6 changes: 3 additions & 3 deletions be/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1120,10 +1120,10 @@ DECLARE_mInt32(schema_cache_capacity);
DECLARE_mInt32(schema_cache_sweep_time_sec);

// max number of segment cache
DECLARE_mInt32(segment_cache_capacity);
DECLARE_mInt32(estimated_num_columns_per_segment);
DECLARE_mInt32(estimated_mem_per_column_reader);
DECLARE_Int32(segment_cache_capacity);
DECLARE_Int32(segment_cache_fd_percentage);
DECLARE_Int32(segment_cache_memory_percentage);
DECLARE_mInt32(estimated_mem_per_column_reader);

// enable binlog
DECLARE_Bool(enable_feature_binlog);
Expand Down
15 changes: 6 additions & 9 deletions be/src/runtime/exec_env_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,21 +518,18 @@ Status ExecEnv::_init_mem_env() {
// SegmentLoader caches segments in rowset granularity. So the size of
// opened files will greater than segment_cache_capacity.
int64_t segment_cache_capacity = config::segment_cache_capacity;
if (segment_cache_capacity < 0 || segment_cache_capacity > fd_number * 1 / 5) {
segment_cache_capacity = fd_number * 1 / 5;
int64_t segment_cache_fd_limit = fd_number / 100 * config::segment_cache_fd_percentage;
if (segment_cache_capacity < 0 || segment_cache_capacity > segment_cache_fd_limit) {
segment_cache_capacity = segment_cache_fd_limit;
}

int64_t segment_cache_mem_limit =
MemInfo::mem_limit() / 100 * config::segment_cache_memory_percentage;
// config::segment_cache_memory_percentage;
int64_t min_segment_cache_mem_limit =
min(segment_cache_mem_limit, segment_cache_capacity *
config::estimated_num_columns_per_segment *
config::estimated_mem_per_column_reader);
_segment_loader = new SegmentLoader(min_segment_cache_mem_limit, segment_cache_capacity);

_segment_loader = new SegmentLoader(segment_cache_mem_limit, segment_cache_capacity);
LOG(INFO) << "segment_cache_capacity <= fd_number * 1 / 5, fd_number: " << fd_number
<< " segment_cache_capacity: " << segment_cache_capacity
<< " min_segment_cache_mem_limit " << min_segment_cache_mem_limit;
<< " min_segment_cache_mem_limit " << segment_cache_mem_limit;

_schema_cache = new SchemaCache(config::schema_cache_capacity);

Expand Down

0 comments on commit 0a17104

Please sign in to comment.