diff --git a/integration/test_info.py b/integration/test_info.py index b2102722d..007e12bfe 100644 --- a/integration/test_info.py +++ b/integration/test_info.py @@ -53,7 +53,20 @@ def test_info_fields_present(self): "search_total_active_write_threads", "search_total_indexing_time", "search_used_memory_bytes", - "search_index_reclaimable_memory" + "search_index_reclaimable_memory", + "search_used_memory_indexes", + "search_smallest_memory_index", + "search_largest_memory_index", + "search_used_memory_vector_index", + "search_global_idle_user", + "search_global_idle_internal", + "search_global_total_user", + "search_global_total_internal", + "search_gc_bytes_collected", + "search_gc_total_cycles", + "search_gc_total_ms_run", + "search_gc_total_docs_not_collected", + "search_gc_marked_deleted_vectors" ] string_fields = [ @@ -61,7 +74,10 @@ def test_info_fields_present(self): ] bytes_fields = [ - "search_used_memory_human" + "search_used_memory_human", + "search_used_memory_indexes_human", + "search_smallest_memory_index_human", + "search_largest_memory_index_human" ] double_fields = [ diff --git a/src/valkey_search.cc b/src/valkey_search.cc index ad05889d9..c71f539fd 100644 --- a/src/valkey_search.cc +++ b/src/valkey_search.cc @@ -114,6 +114,79 @@ static vmsdk::info_field::Integer reclaimable_memory( }) .CrashSafe()); +static vmsdk::info_field::Integer used_memory_indexes( + "memory", "used_memory_indexes", + vmsdk::info_field::IntegerBuilder() + .App() + .Computed([]() -> uint64_t { + // TODO: need to implement actual memory calculation for indexes + return 0; + }) + .CrashSafe()); + +static vmsdk::info_field::Integer used_memory_indexes_human( + "memory", "used_memory_indexes_human", + vmsdk::info_field::IntegerBuilder() + .SIBytes() + .App() + .Computed([]() -> uint64_t { + // TODO: need to implement actual memory calculation for indexes + return 0; + }) + .CrashSafe()); + +static vmsdk::info_field::Integer smallest_memory_index( + "memory", "smallest_memory_index", + vmsdk::info_field::IntegerBuilder() + .App() + .Computed([]() -> uint64_t { + // TODO: need to implement actual memory calculation for smallest index + return 0; + }) + .CrashSafe()); + +static vmsdk::info_field::Integer smallest_memory_index_human( + "memory", "smallest_memory_index_human", + vmsdk::info_field::IntegerBuilder() + .SIBytes() + .App() + .Computed([]() -> uint64_t { + // TODO: need to implement actual memory calculation for smallest index + return 0; + }) + .CrashSafe()); + +static vmsdk::info_field::Integer largest_memory_index( + "memory", "largest_memory_index", + vmsdk::info_field::IntegerBuilder() + .App() + .Computed([]() -> uint64_t { + // TODO: need to implement actual memory calculation for largest index + return 0; + }) + .CrashSafe()); + +static vmsdk::info_field::Integer largest_memory_index_human( + "memory", "largest_memory_index_human", + vmsdk::info_field::IntegerBuilder() + .SIBytes() + .App() + .Computed([]() -> uint64_t { + // TODO: need to implement actual memory calculation for largest index + return 0; + }) + .CrashSafe()); + +static vmsdk::info_field::Integer used_memory_vector_index( + "memory", "used_memory_vector_index", + vmsdk::info_field::IntegerBuilder() + .App() + .Computed([]() -> uint64_t { + // TODO: need to implement actual memory calculation for vector index + return 0; + }) + .CrashSafe()); + static vmsdk::info_field::String background_indexing_status( "indexing", "background_indexing_status", vmsdk::info_field::StringBuilder().App().ComputedCharPtr( @@ -815,9 +888,73 @@ static vmsdk::info_field::Integer &remove_subscription_failure_count = remove_subscription_fields[1]; static vmsdk::info_field::Integer &remove_subscription_skipped_count = remove_subscription_fields[2]; - #endif +// Search cursors info fields +static vmsdk::info_field::Integer global_idle_user( + "cursors", "global_idle_user", + vmsdk::info_field::IntegerBuilder().App().Computed([]() -> long long { + // TODO: need to implement actual cursor idle user count + return 0; + })); + +static vmsdk::info_field::Integer global_idle_internal( + "cursors", "global_idle_internal", + vmsdk::info_field::IntegerBuilder().App().Computed([]() -> long long { + // TODO: need to implement actual cursor idle internal count + return 0; + })); + +static vmsdk::info_field::Integer global_total_user( + "cursors", "global_total_user", + vmsdk::info_field::IntegerBuilder().App().Computed([]() -> long long { + // TODO: need to implement actual cursor total user count + return 0; + })); + +static vmsdk::info_field::Integer global_total_internal( + "cursors", "global_total_internal", + vmsdk::info_field::IntegerBuilder().App().Computed([]() -> long long { + // TODO: need to implement actual cursor total internal count + return 0; + })); + +// Search garbage collector info fields +static vmsdk::info_field::Integer gc_bytes_collected( + "garbage_collector", "gc_bytes_collected", + vmsdk::info_field::IntegerBuilder().App().Computed([]() -> long long { + // TODO: need to implement actual GC bytes collected + return 0; + })); + +static vmsdk::info_field::Integer gc_total_cycles( + "garbage_collector", "gc_total_cycles", + vmsdk::info_field::IntegerBuilder().App().Computed([]() -> long long { + // TODO: need to implement actual GC total cycles + return 0; + })); + +static vmsdk::info_field::Integer gc_total_ms_run( + "garbage_collector", "gc_total_ms_run", + vmsdk::info_field::IntegerBuilder().App().Computed([]() -> long long { + // TODO: need to implement actual GC total milliseconds run + return 0; + })); + +static vmsdk::info_field::Integer gc_total_docs_not_collected( + "garbage_collector", "gc_total_docs_not_collected", + vmsdk::info_field::IntegerBuilder().App().Computed([]() -> long long { + // TODO: need to implement actual GC total docs not collected + return 0; + })); + +static vmsdk::info_field::Integer gc_marked_deleted_vectors( + "garbage_collector", "gc_marked_deleted_vectors", + vmsdk::info_field::IntegerBuilder().App().Computed([]() -> long long { + // TODO: need to implement actual GC marked deleted vectors + return 0; + })); + static vmsdk::info_field::Integer string_interning_memory_bytes("string_interning", "string_interning_memory_bytes", vmsdk::info_field::IntegerBuilder() .App() diff --git a/testing/valkey_search_test.cc b/testing/valkey_search_test.cc index 6e1a2535e..7e0b36b7d 100644 --- a/testing/valkey_search_test.cc +++ b/testing/valkey_search_test.cc @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include "absl/synchronization/mutex.h" #include "absl/time/clock.h" @@ -475,8 +477,11 @@ TEST_F(ValkeySearchTest, Info) { "index_stats\nnumber_of_indexes: 1\nnumber_of_attributes: 1\ntotal_indexed_documents: 4\nnumber_of_active_indexes: 1\n" "number_of_active_indexes_running_queries: 0\nnumber_of_active_indexes_indexing: 1\n" "total_active_write_threads: 5\ntotal_indexing_time: 0\n" - "indexing\nbackground_indexing_status: 'IN_PROGRESS'\n" - "memory\nused_memory_bytes: 18408\nused_memory_human: '17.98KiB'\n" + "indexing\nbackground_indexing_status: 'IN_PROGRESS'\nmemory\nused_memory_bytes: 18408\nused_memory_human: '17.98KiB'\n" + "used_memory_indexes: 0\nused_memory_indexes_human: 0\nsmallest_memory_index: 0\nsmallest_memory_index_human: 0\n" + "largest_memory_index: 0\nlargest_memory_index_human: 0\nused_memory_vector_index: 0\ncursors\nglobal_idle_user: 0\n" + "global_idle_internal: 0\nglobal_total_user: 0\nglobal_total_internal: 0\ngarbage_collector\ngc_bytes_collected: 0\n" + "gc_total_cycles: 0\ngc_total_ms_run: 0\ngc_total_docs_not_collected: 0\ngc_marked_deleted_vectors: 0\n" ); #endif StringInternStore::SetMemoryUsage(0); // reset memory pool