-
Notifications
You must be signed in to change notification settings - Fork 35
feature: Per index logger and new logger unit test for each index #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: Per index logger and new logger unit test for each index #87
Conversation
include/svs/core/logging.h
Outdated
| Level::Critical, | ||
| Level::Off}; | ||
| Level::Off | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please run these commands from the repository's root to ensure all the formatting is consistent?
sudo apt install clang-format-15
bash tools/clang-format.sh clang-format-15
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thx!
include/svs/core/logging.h
Outdated
| inline void set_global_log_callback(log_callback_function callback) { | ||
| global_log_callback = callback; | ||
| std::cout << "[DEBUG] set_global_log_callback(" << reinterpret_cast<void*>(callback) | ||
| << ")\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove the std::cout print statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed, thx!
include/svs/index/vamana/index.h
Outdated
| /// search. This may be included to perform operations like reranking for quantized | ||
| /// datasets. | ||
| /// @tparam log_callback_ctx A pointer to a user-defined context for per-index logging | ||
| /// customization. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove the logger from here as it is not the template parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed, thx!
rfsaliev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this change breaks existing SVS logging design based on spdlog.
IMHO, instead of log_callback_ctx we should use logger_ptr.
In such case user will follow known spdlog approach for custom loggers (including contexts) rather than than learn one more SVS-specific approach (with the risk of typos like "DЕBYG" instead of "DEBUG").
And there is still global logger used, e.g. in MutableVamanaIndex::consolidate()
include/svs/index/flat/flat.h
Outdated
| Data data, | ||
| Dist distance, | ||
| ThreadPoolProto threadpool_proto, | ||
| void* log_callback_ctx = nullptr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, svs::logger_ptr would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx, that make sense, changed!
That's a good idea! I changed the code to use sink component and make shared function in spdlog. But not too sure about functions like MutableVamanaIndex::consolidate(). It looks like these loggers are just used for debugging, do we want them to have per index logging as well? |
|
Now that we have per-index-instance logger, each member function in the index should use that logger. For example, Note that we have logging information in construct as well. We should also delegate the per-index-instance logger to that construct for logging rather than the global logger. |
Thx for the help! Now these files are using per index logging :D |
| // const double DELETE_PERCENT = 0.05; | ||
| // #endif | ||
|
|
||
| // CATCH_TEST_CASE("MutableVamanaIndex", "[graph_index]") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we comment out this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are removed already, dynamic_index.cpp is not changed, only dynamic_index_2.cpp is added a new test
tests/svs/index/vamana/index.cpp
Outdated
| std::string prefix; | ||
| }; | ||
|
|
||
| static void test_log_impl(void* ctx, const char* level, const char* message) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure the purpose of static in every test_log_impl. I think putting this function and the struct into anonymous namespace is enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see it anymore, seems to be older old?
| << post_add_time << " seconds." << std::endl; | ||
| } | ||
| } | ||
| CATCH_TEST_CASE("Dynamic MutableVamanaIndex Per-Index Logging Test", "[logging]") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add a test for not setting the callback (i.e., not calling set_global_log_callback)? Adding this test in dynamic index should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx! Added in dynamic_index_2.cpp
| /// @brief Add the points with the given external IDs to the dataset. | ||
| // | ||
| /// When `delete_entries` is called, a soft deletion is performed, marking the entries | ||
| /// as `deleted`. When `consolidate` is called, the state of these deleted entries becomes `empty`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a side note that I notice clang-format keeps changing the format of this paragraph. We might want to consider disabling clang-format for this specific section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, this part will not change
| } | ||
|
|
||
| /// @brief Getter method for logger | ||
| svs::logging::logger_ptr get_logger() const { return logger_; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have this get_logger for each index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx, added logger getter for each index
|
|
||
| // Verify the custom logger captured the log messages | ||
| CATCH_REQUIRE(captured_logs[0].find("Number of syncs:") != std::string::npos); | ||
| CATCH_REQUIRE(captured_logs[1].find("Batch Size:") != std::string::npos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also test here to check if the global logger is not used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx, added!
include/svs/index/vamana/index.h
Outdated
| I{}, | ||
| std::move(distance), | ||
| std::move(threadpool), | ||
| logger}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| logger}; | |
| std::move(logger)}; |
should we move instead of copy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, changed!
This PR intends to add per index logging feature to help the redis integration progress