Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 6 additions & 1 deletion be/src/cloud/cloud_index_change_compaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ Status CloudIndexChangeCompaction::prepare_compact() {
_input_rowsets_total_size += rs->total_disk_size();
}

_enable_inverted_index_compaction = false;
// Non-SNII compaction cannot reuse index files when the index schema changes. SNII validates
// each destination logical index independently and rebuilds ineligible columns from raw data.
_enable_inverted_index_compaction =
_enable_inverted_index_compaction &&
input_rowset->tablet_schema()->get_inverted_index_storage_format() ==
InvertedIndexStorageFormatPB::SNII;
LOG_INFO("[index_change]prepare CloudIndexChangeCompaction, tablet_id={}, range=[{}-{}]",
_tablet->tablet_id(), _input_rowsets.front()->start_version(),
_input_rowsets.back()->end_version())
Expand Down
4 changes: 2 additions & 2 deletions be/src/cloud/cloud_internal_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ void record_warmup_ed_fail_index(const std::string& job_id_str, int64_t idx_size
void record_warmup_ed_skipped_rowset_as_finished(RowsetMeta& rs_meta,
const std::string& job_id_str) {
auto schema_ptr = rs_meta.tablet_schema();
bool has_inverted_index = schema_ptr->has_inverted_index() || schema_ptr->has_ann_index();
bool has_inverted_index = schema_ptr->has_inverted_or_ann_index();
auto idx_version = schema_ptr->get_inverted_index_storage_format();
for (int64_t segment_id = 0; segment_id < rs_meta.num_segments(); segment_id++) {
record_warmup_ed_finish_segment(job_id_str, rs_meta.segment_file_size(segment_id));
Expand Down Expand Up @@ -1289,7 +1289,7 @@ void CloudInternalServiceImpl::warm_up_rowset(google::protobuf::RpcController* c
auto schema_ptr = rs_meta.tablet_schema();
auto idx_version = schema_ptr->get_inverted_index_storage_format();

if (schema_ptr->has_inverted_index() || schema_ptr->has_ann_index()) {
if (schema_ptr->has_inverted_or_ann_index()) {
if (idx_version == InvertedIndexStorageFormatPB::V1) {
auto&& inverted_index_info = rs_meta.inverted_index_file_info(segment_id);
std::unordered_map<int64_t, int64_t> index_size_map;
Expand Down
2 changes: 1 addition & 1 deletion be/src/cloud/cloud_rowset_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Status CloudRowsetWriter::build(RowsetSharedPtr& rowset) {
} else {
_rowset_meta->add_segments_file_size(seg_file_size.value());
}
if (_context.tablet_schema->has_inverted_index() || _context.tablet_schema->has_ann_index()) {
if (_context.tablet_schema->has_inverted_or_ann_index()) {
if (auto idx_files_info = _idx_files.inverted_index_file_info(_segment_start_id);
!idx_files_info.has_value()) [[unlikely]] {
LOG(ERROR) << "expected inverted index files info, but none presents: "
Expand Down
3 changes: 1 addition & 2 deletions be/src/cloud/cloud_snapshot_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ Status CloudSnapshotMgr::_create_rowset_meta(
file_mapping[src_index_file] = dst_index_file;
}
} else {
if (context.tablet_schema->has_inverted_index() ||
context.tablet_schema->has_ann_index()) {
if (context.tablet_schema->has_inverted_or_ann_index()) {
std::string src_index_file = InvertedIndexDescriptor::get_index_file_path_v2(
InvertedIndexDescriptor::get_index_file_path_prefix(src_segment_file));
std::string dst_index_file = InvertedIndexDescriptor::get_index_file_path_v2(
Expand Down
2 changes: 1 addition & 1 deletion be/src/cloud/cloud_tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,7 @@ void CloudTablet::_add_rowsets_directly(std::vector<RowsetSharedPtr>& rowsets,
expiration_time);
}
} else {
if (schema_ptr->has_inverted_index() || schema_ptr->has_ann_index()) {
if (schema_ptr->has_inverted_or_ann_index()) {
auto&& inverted_index_info = rowset_meta->inverted_index_file_info(seg_id);
int64_t idx_size = 0;
if (inverted_index_info.has_index_size()) {
Expand Down
4 changes: 2 additions & 2 deletions be/src/cloud/cloud_warm_up_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ void CloudWarmUpManager::handle_jobs() {
tablet_id);
}
} else {
if (schema_ptr->has_inverted_index() || schema_ptr->has_ann_index()) {
if (schema_ptr->has_inverted_or_ann_index()) {
auto idx_path =
storage_resource.value()->remote_idx_v2_path(*rs, seg_id);
file_size = idx_file_info.has_index_size() ? idx_file_info.index_size()
Expand Down Expand Up @@ -853,7 +853,7 @@ Status CloudWarmUpManager::_do_warm_up_rowset(RowsetMeta& rs_meta, int64_t table
g_file_cache_event_driven_warm_up_requested_segment_size << seg_size;
g_warmup_ed_requested_segment_size.put({job_id_str}, seg_size);

if (schema_ptr->has_inverted_index() || schema_ptr->has_ann_index()) {
if (schema_ptr->has_inverted_or_ann_index()) {
if (idx_version == InvertedIndexStorageFormatPB::V1) {
auto&& inverted_index_info =
rs_meta.inverted_index_file_info(cast_set<int>(segment_id));
Expand Down
73 changes: 64 additions & 9 deletions be/src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@
// IWYU pragma: no_include <bthread/errno.h>
#include <lz4/lz4hc.h>

#include <atomic>
#include <cerrno> // IWYU pragma: keep
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <fstream> // IWYU pragma: keep
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <mutex>
Expand Down Expand Up @@ -1343,6 +1346,17 @@ DEFINE_Bool(enable_inverted_index_cache_check_timestamp, "true");
DEFINE_mBool(enable_inverted_index_correct_term_write, "true");
DEFINE_Int32(inverted_index_fd_number_limit_percent, "20"); // 20%
DEFINE_Int32(inverted_index_query_cache_shards, "256");
DEFINE_mDouble(inverted_index_candidate_pushdown_ratio, "0.3");
DEFINE_Validator(inverted_index_candidate_pushdown_ratio,
[](const double v) -> bool { return std::isfinite(v) && v <= 1.0; });
static std::atomic<double> published_inverted_index_candidate_pushdown_ratio {0.0};
DEFINE_ON_UPDATE(inverted_index_candidate_pushdown_ratio, [](double, double value) {
published_inverted_index_candidate_pushdown_ratio.store(value);
});

double get_inverted_index_candidate_pushdown_ratio() {
return published_inverted_index_candidate_pushdown_ratio.load();
}

// inverted index match bitmap cache size
DEFINE_String(inverted_index_query_cache_limit, "10%");
Expand All @@ -1355,6 +1369,43 @@ DEFINE_mDouble(inverted_index_ram_buffer_size, "512");
// -1 indicates not working.
// Normally we should not change this, it's useful for testing.
DEFINE_mInt32(inverted_index_max_buffered_docs, "-1");
// Zstd levels for SNII DICT blocks and .prx windows. These affect writes; each segment records its compression mode.
DEFINE_mInt32(snii_dict_block_zstd_level, "3");
DEFINE_mInt32(snii_prx_zstd_level, "3");
// Zstd level for direct-load .prx regions. Compaction rewrites them using snii_prx_zstd_level.
DEFINE_mInt32(snii_prx_zstd_level_direct_load, "3");
// G16-d: target SNII dict block size in bytes; 0 uses the format default
// (64 KiB). Larger blocks compress better under the per-block zstd (the dict
// is the dominant physical section on high-cardinality corpora) at the cost
// of a larger fetch+decompress unit per cold dict-block miss. Write side
// only; the block size is self-described by the on-disk directory.
DEFINE_mInt32(snii_target_dict_block_bytes, "0");
// SNII's index-build share of the process memory limit, as a percent -- the
// index-build analogue of load_process_max_memory_limit_percent. Once live SNII
// index-build memory crosses this share, the largest reclaimable posting arenas
// are asked to spill early. Derived from the process limit rather than an
// absolute number so it scales with the BE. Only the RECLAIMABLE population
// counts against it: index-merge compaction charges the same observation
// tracker but registers no spillable writer, so its bytes are excluded from the
// comparison (its own hard reservation cap bounds them instead).
//
// 0 disables SNII's OWN share trigger; the process-level backstops (system
// available memory below its warning water mark, process usage above the soft
// limit) still apply. The share is deliberately well below those backstops so
// SNII sheds its own memory before the global valve -- the global valve trips
// late by design and would be a worse trigger than none. The derived share is
// floored at four times inverted_index_ram_buffer_size so a small BE is not
// permanently over it the moment two writers exist.
DEFINE_mInt32(snii_index_build_max_memory_limit_percent, "10");
// Minimum reclaimable posting-arena bytes before a G09 forced spill is honored
// (and before a writer is eligible as a spill victim): forced spills reclaim
// ONLY the arena, so smaller triggers cut tiny runs for near-zero relief.
// Default 64 MiB.
DEFINE_mInt64(snii_forced_spill_min_arena_bytes, "67108864");
// Max spill-run files one SNII writer accumulates before its runs are
// merge-compacted into one (bounds the k-way merge fan-in and its open fds;
// every run is held open for the whole merge). 0 = uncapped. Default 64.
DEFINE_mInt32(snii_spill_max_run_files_per_buffer, "64");
// dict path for chinese analyzer
DEFINE_String(inverted_index_dict_path, "${DORIS_HOME}/dict");
DEFINE_Int32(inverted_index_read_buffer_size, "4096");
Expand Down Expand Up @@ -2213,6 +2264,8 @@ bool init(const char* conf_file, bool fill_conf_map, bool must_exist, bool set_t
SET_FIELD(it.second, std::vector<double>, fill_conf_map, set_to_default);
SET_FIELD(it.second, std::vector<std::string>, fill_conf_map, set_to_default);
}
published_inverted_index_candidate_pushdown_ratio.store(
inverted_index_candidate_pushdown_ratio);

if (config::is_cloud_mode()) {
auto st = config::set_config("enable_file_cache", "true", true, true);
Expand Down Expand Up @@ -2243,14 +2296,18 @@ bool init(const char* conf_file, bool fill_conf_map, bool must_exist, bool set_t
(FIELD).name, new_value); \
} \
} \
if (PERSIST) { \
Status persist_status = persist_config(std::string((FIELD).name), VALUE); \
if (!persist_status.ok()) { \
ref_conf_value = old_value; \
return persist_status; \
} \
} \
if (full_conf_map != nullptr) { \
std::ostringstream oss; \
oss << new_value; \
(*full_conf_map)[(FIELD).name] = oss.str(); \
} \
if (PERSIST) { \
RETURN_IF_ERROR(persist_config(std::string((FIELD).name), VALUE)); \
} \
if (RegisterConfUpdateCallback::_s_field_update_callback != nullptr) { \
auto callback_it = \
RegisterConfUpdateCallback::_s_field_update_callback->find((FIELD).name); \
Expand All @@ -2268,7 +2325,7 @@ Status persist_config(const std::string& field, const std::string& value) {
// lock to make sure only one thread can modify the be_custom.conf
std::lock_guard<std::mutex> l(custom_conf_lock);

static const std::string conffile = config::custom_config_dir + "/be_custom.conf";
const std::string conffile = config::custom_config_dir + "/be_custom.conf";

Properties tmp_props;
if (!tmp_props.load(conffile.c_str(), false)) {
Expand All @@ -2292,16 +2349,14 @@ Status set_config(const std::string& field, const std::string& value, bool need_
"'{}' is not support to modify", field);
}

// Keep the value, config map, and callback in the same update order.
std::lock_guard<std::mutex> lock(mutable_string_config_lock);
UPDATE_FIELD(it->second, value, bool, need_persist);
UPDATE_FIELD(it->second, value, int16_t, need_persist);
UPDATE_FIELD(it->second, value, int32_t, need_persist);
UPDATE_FIELD(it->second, value, int64_t, need_persist);
UPDATE_FIELD(it->second, value, double, need_persist);
{
// add lock to ensure thread safe
std::lock_guard<std::mutex> lock(mutable_string_config_lock);
UPDATE_FIELD(it->second, value, std::string, need_persist);
}
UPDATE_FIELD(it->second, value, std::string, need_persist);

// The other types are not thread safe to change dynamically.
return Status::Error<ErrorCode::NOT_IMPLEMENTED_ERROR, false>(
Expand Down
29 changes: 29 additions & 0 deletions be/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1365,16 +1365,45 @@ DECLARE_Bool(enable_inverted_index_cache_check_timestamp);
DECLARE_mBool(enable_inverted_index_correct_term_write);
DECLARE_Int32(inverted_index_fd_number_limit_percent); // 50%
DECLARE_Int32(inverted_index_query_cache_shards);
// When the candidate row bitmap of a segment scan is smaller than
// num_rows * this ratio, it is pushed down into inverted index queries so
// doc-list intersection and verification run only over the candidates
// (see IndexQueryContext::candidate_rows). <= 0 disables the pushdown.
DECLARE_mDouble(inverted_index_candidate_pushdown_ratio);
double get_inverted_index_candidate_pushdown_ratio();

// inverted index match bitmap cache size
DECLARE_String(inverted_index_query_cache_limit);

// Build-only CommonGrams kill switch. Logical index writers snapshot it at construction; changing
// it affects only writers created after the transition and never changes query/cache semantics.
// Release-calibrated query-planner coefficients. Both remain mutable for controlled recalibration.

// condition cache limit
DECLARE_Int16(condition_cache_limit);

// inverted index
DECLARE_mDouble(inverted_index_ram_buffer_size);
DECLARE_mInt32(inverted_index_max_buffered_docs);
// G16-h: zstd levels for SNII dict blocks / prx windows. Default 3 (the
// all-level-3 evaluation showed level 9 buys <=6.3% index size for 17-24%
// import CPU; see the DEFINEs in config.cpp).
DECLARE_mInt32(snii_dict_block_zstd_level);
DECLARE_mInt32(snii_prx_zstd_level);
// Patch C: prx zstd level for DIRECT-LOAD segments only (default 3, cheaper
// import); compaction rewrites at snii_prx_zstd_level so settled segments are
// unaffected. Full contract at the DEFINE in config.cpp.
DECLARE_mInt32(snii_prx_zstd_level_direct_load);
// G16-d: target SNII dict block size in bytes; 0 = format default (64 KiB).
// Bigger blocks -> better per-block zstd on the dict region, larger cold
// fetch+decompress unit per dict-block miss. Write side only.
DECLARE_mInt32(snii_target_dict_block_bytes);
// Maximum process-memory share for SNII index builds. Above this share, writers with reclaimable posting arenas receive spill requests; zero disables the share trigger but keeps process-pressure backstops.
DECLARE_mInt32(snii_index_build_max_memory_limit_percent);
// Minimum reclaimable posting-arena size for a forced spill. Requests below this floor remain pending until the arena grows enough.
DECLARE_mInt64(snii_forced_spill_min_arena_bytes);
// Maximum spill runs held by one SNII writer. Runs are merged when this cap is exceeded to bound merge fan-in and open file descriptors; zero disables the cap.
DECLARE_mInt32(snii_spill_max_run_files_per_buffer);
// dict path for chinese analyzer
DECLARE_String(inverted_index_dict_path);
DECLARE_Int32(inverted_index_read_buffer_size);
Expand Down
1 change: 1 addition & 0 deletions be/src/common/metrics/doris_metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class DorisMetrics {
UIntGauge* load_mem_consumption = nullptr;
UIntGauge* load_channel_mem_consumption = nullptr;
UIntGauge* memtable_memory_limiter_mem_consumption = nullptr;
UIntGauge* snii_index_build_mem_consumption = nullptr;
UIntGauge* query_mem_consumption = nullptr;
UIntGauge* schema_change_mem_consumption = nullptr;
UIntGauge* storage_migration_mem_consumption = nullptr;
Expand Down
1 change: 1 addition & 0 deletions be/src/common/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ namespace ErrorCode {
E(INVERTED_INDEX_COMPACTION_ERROR, -6010, false); \
E(INVERTED_INDEX_ANALYZER_ERROR, -6011, false); \
E(INVERTED_INDEX_FILE_CORRUPTED, -6012, false); \
E(INVERTED_INDEX_SNII_NOT_FOUND, -6013, false); \
E(KEY_NOT_FOUND, -7000, false); \
E(KEY_ALREADY_EXISTS, -7001, false); \
E(ENTRY_NOT_FOUND, -7002, false); \
Expand Down
8 changes: 8 additions & 0 deletions be/src/exec/operator/olap_scan_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ Status OlapScanLocalState::_init_profile() {
ADD_COUNTER_WITH_LEVEL(_segment_profile, "InvertedIndexQueryCacheHit", TUnit::UNIT, 1);
_inverted_index_query_cache_miss_counter =
ADD_COUNTER_WITH_LEVEL(_segment_profile, "InvertedIndexQueryCacheMiss", TUnit::UNIT, 1);
_inverted_index_query_cache_lookup_counter = ADD_COUNTER_WITH_LEVEL(
_segment_profile, "InvertedIndexQueryCacheLookup", TUnit::UNIT, 1);
_inverted_index_query_cache_insert_counter = ADD_COUNTER_WITH_LEVEL(
_segment_profile, "InvertedIndexQueryCacheInsert", TUnit::UNIT, 1);
_inverted_index_query_timer =
ADD_TIMER_WITH_LEVEL(_segment_profile, "InvertedIndexQueryTime", 1);
_inverted_index_query_null_bitmap_timer =
Expand All @@ -275,6 +279,8 @@ Status OlapScanLocalState::_init_profile() {
_segment_profile, "InvertedIndexSearcherCacheMiss", TUnit::UNIT, 1);
_inverted_index_downgrade_count_counter =
ADD_COUNTER_WITH_LEVEL(_segment_profile, "InvertedIndexDowngradeCount", TUnit::UNIT, 1);
_inverted_index_conjuncts_short_circuited_counter = ADD_COUNTER_WITH_LEVEL(
_segment_profile, "InvertedIndexConjunctsShortCircuited", TUnit::UNIT, 1);
_inverted_index_analyzer_timer =
ADD_TIMER_WITH_LEVEL(_segment_profile, "InvertedIndexAnalyzerTime", 1);
_inverted_index_lookup_timer =
Expand Down Expand Up @@ -328,6 +334,8 @@ Status OlapScanLocalState::_init_profile() {

_index_filter_profile = std::make_unique<RuntimeProfile>("IndexFilter");
_scanner_profile->add_child(_index_filter_profile.get(), true, nullptr);
_snii_prx_profile_counters.initialize(_index_filter_profile.get());
_snii_phrase_profile_counters.initialize(_index_filter_profile.get());
/*
SegmentIterator:
- AnnIndexLoadCosts: 102.262us
Expand Down
Loading
Loading