Skip to content

Commit

Permalink
[Improve] Use number of columns to count segment cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Lchangliang committed Jan 9, 2024
1 parent 8a1fd83 commit ed5c650
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions be/src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@ 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(each_segment_have_columns, "30");

// enable feature binlog, default false
DEFINE_Bool(enable_feature_binlog, "false");
Expand Down
1 change: 1 addition & 0 deletions be/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,7 @@ DECLARE_mInt32(schema_cache_sweep_time_sec);

// max number of segment cache
DECLARE_mInt32(segment_cache_capacity);
DECLARE_mInt32(each_segment_have_columns);

// enable binlog
DECLARE_Bool(enable_feature_binlog);
Expand Down
2 changes: 2 additions & 0 deletions be/src/olap/rowset/segment_v2/segment.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ class Segment : public std::enable_shared_from_this<Segment> {
return safe;
}

const TabletSchemaSPtr& tablet_schema() { return _tablet_schema; }

private:
DISALLOW_COPY_AND_ASSIGN(Segment);
Segment(uint32_t segment_id, RowsetId rowset_id, TabletSchemaSPtr tablet_schema);
Expand Down
5 changes: 3 additions & 2 deletions be/src/olap/segment_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ void SegmentCache::insert(const SegmentCache::CacheKey& key, SegmentCache::Cache
delete cache_value;
};

auto lru_handle = cache()->insert(key.encode(), &value, 1, deleter, CachePriority::NORMAL,
value.segment->meta_mem_usage());
auto lru_handle =
cache()->insert(key.encode(), &value, value.segment->tablet_schema()->num_columns(),
deleter, CachePriority::NORMAL, 0);
handle->push_segment(cache(), lru_handle);
}

Expand Down
2 changes: 1 addition & 1 deletion be/src/runtime/exec_env_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ Status ExecEnv::_init_mem_env() {
}
LOG(INFO) << "segment_cache_capacity <= fd_number * 2 / 5, fd_number: " << fd_number
<< " segment_cache_capacity: " << segment_cache_capacity;
_segment_loader = new SegmentLoader(segment_cache_capacity);
_segment_loader = new SegmentLoader(segment_cache_capacity * config::each_segment_have_columns);

_schema_cache = new SchemaCache(config::schema_cache_capacity);

Expand Down

0 comments on commit ed5c650

Please sign in to comment.