Skip to content

Commit dcd209f

Browse files
committed
Merge remote-tracking branch 'origin/2.6' into backport-6574-to-2.6
2 parents 4153e24 + 24db9e8 commit dcd209f

File tree

6 files changed

+21
-11
lines changed

6 files changed

+21
-11
lines changed

src/info/indexes_info.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,19 @@ TotalIndexesInfo IndexesInfo_TotalInfo() {
2525
if (!sp) {
2626
continue;
2727
}
28-
// Lock for read
29-
size_t cur_mem = IndexSpec_TotalMemUsage(sp, 0, 0, 0);
30-
info.total_mem += cur_mem;
31-
if (info.min_mem > cur_mem) info.min_mem = cur_mem;
32-
if (info.max_mem < cur_mem) info.max_mem = cur_mem;
33-
info.indexing_time += sp->stats.totalIndexTime;
3428

3529
// Vector index stats
3630
VectorIndexStats vec_info = IndexSpec_GetVectorIndexStats(sp);
3731
info.fields_stats.total_vector_idx_mem += vec_info.memory;
3832
info.fields_stats.total_mark_deleted_vectors += vec_info.marked_deleted;
3933

34+
size_t cur_mem = IndexSpec_TotalMemUsage(sp, 0, 0, 0, vec_info.memory);
35+
info.total_mem += cur_mem;
36+
37+
if (info.min_mem > cur_mem) info.min_mem = cur_mem;
38+
if (info.max_mem < cur_mem) info.max_mem = cur_mem;
39+
info.indexing_time += sp->stats.totalIndexTime;
40+
4041
if (sp->gc) {
4142
ForkGCStats gcStats = ((ForkGC *)sp->gc->gcCtx)->stats;
4243
info.gc_stats.totalCollectedBytes += gcStats.totalCollected;

src/info/info_command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ int IndexInfoCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
221221
size_t text_overhead = IndexSpec_collect_text_overhead(sp);
222222
REPLY_KVNUM(n, "text_overhead_sz_mb", text_overhead / (float)0x100000);
223223
REPLY_KVNUM(n, "total_index_memory_sz_mb", IndexSpec_TotalMemUsage(sp, dt_tm_size,
224-
tags_overhead, text_overhead) / (float)0x100000);
224+
tags_overhead, text_overhead, sp->stats.vectorIndexSize) / (float)0x100000);
225225
REPLY_KVNUM(n, "records_per_doc_avg",
226226
(float)sp->stats.numRecords / (float)sp->stats.numDocuments);
227227
REPLY_KVNUM(n, "bytes_per_record_avg",

src/redisearch_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ int RediSearch_IndexInfo(RSIndex* sp, RSIdxInfo *info) {
850850
}
851851

852852
size_t RediSearch_MemUsage(RSIndex* sp) {
853-
return IndexSpec_TotalMemUsage(sp, 0, 0, 0);
853+
return IndexSpec_TotalMemUsage(sp, 0, 0, 0, 0);
854854
}
855855

856856
// Collect statistics of all the currently existing indexes

src/spec.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "rdb.h"
3131
#include "commands.h"
3232
#include "info/global_stats.h"
33+
#include "info/field_spec_info.h"
3334
#include "rs_wall_clock.h"
3435

3536
#define INITIAL_DOC_TABLE_SIZE 1000
@@ -298,7 +299,7 @@ size_t IndexSpec_collect_text_overhead(IndexSpec *sp) {
298299
return overhead;
299300
}
300301

301-
size_t IndexSpec_TotalMemUsage(IndexSpec *sp, size_t doctable_tm_size, size_t tags_overhead, size_t text_overhead) {
302+
size_t IndexSpec_TotalMemUsage(IndexSpec *sp, size_t doctable_tm_size, size_t tags_overhead, size_t text_overhead, size_t vector_overhead) {
302303
size_t res = 0;
303304
res += sp->docs.memsize;
304305
res += sp->docs.sortablesSize;
@@ -308,6 +309,7 @@ size_t IndexSpec_TotalMemUsage(IndexSpec *sp, size_t doctable_tm_size, size_t ta
308309
res += sp->stats.invertedSize;
309310
res += sp->stats.offsetVecsSize;
310311
res += sp->stats.termsSize;
312+
res += vector_overhead;
311313
return res;
312314
}
313315

src/spec.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,14 @@ size_t IndexSpec_collect_text_overhead(IndexSpec *sp);
611611

612612
/**
613613
* @return all memory used by the index `sp`.
614-
* Uses the sizes of the doc-table, tag and text overhead if they are not `0`.
614+
* Uses the sizes of the doc-table, tag and text overhead if they are not `0`
615+
* (otherwise compute them in-place). Vector overhead is expected to be passed in as an argument
616+
* and will not be computed in-place
617+
* TODO: fIx so this will account for the entire index memory, preferably by using an allocator,
618+
* currently it is a best effort that account only for part of the actual memory.
615619
*/
616-
size_t IndexSpec_TotalMemUsage(IndexSpec *sp, size_t doctable_tm_size, size_t tags_overhead, size_t text_overhead);
620+
size_t IndexSpec_TotalMemUsage(IndexSpec *sp, size_t doctable_tm_size, size_t tags_overhead,
621+
size_t text_overhead, size_t vector_overhead);
617622

618623
//---------------------------------------------------------------------------------------------
619624

tests/pytests/test_info_modules.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ def test_redis_info_modules_vecsim(env):
472472
info = env.cmd('INFO', 'MODULES')
473473
field_infos = get_field_infos()
474474
env.assertEqual(info['search_used_memory_vector_index'], sum(field_info['MEMORY'] for field_info in field_infos))
475+
# Validate that vector indexes are accounted in the total index memory
476+
env.assertGreater(info['search_used_memory_indexes'], info['search_used_memory_vector_index'])
475477
env.assertEqual(info['search_marked_deleted_vectors'], 0)
476478

477479
set_doc().equal(0) # Add (override) the document with a new one

0 commit comments

Comments
 (0)