Repository navigation
Set prefetching based on the converted index - #490
Conversation
ethanglaser
left a comment
There was a problem hiding this comment.
Overall looking good, just a few minor questions/suggestions
| auto prefetch = svs::index::vamana::extensions::estimate_prefetch_parameters(data); | ||
| config.search_parameters.prefetch_lookahead(prefetch.lookahead) | ||
| .prefetch_step(prefetch.step); |
There was a problem hiding this comment.
This re-estimates unconditionally, so any prefetch settings the user tuned on the source (e.g. via calibration, then saved) are replaced by the heuristic even when the per-vector size doesn't change (fp32 → fp32 with a different allocator, etc.). Should we only re-estimate when the destination's bytes-per-vector differs from the source's, or otherwise document that conversion always resets prefetch? Same applies in dispatcher_dynamic_vamana_copy.hpp.
There was a problem hiding this comment.
Instead of looking a the bytes-per-vector, which is a details, I changed the code to change prefetching only when the actual estimates for the old and new data differ.
| // The source's search parameters carry prefetch settings estimated from the source | ||
| // data. Re-estimate them for the converted data, as a freshly built index would. | ||
| { | ||
| auto prefetch = svs::index::vamana::extensions::estimate_prefetch_parameters(data); | ||
| config.search_parameters.prefetch_lookahead(prefetch.lookahead) | ||
| .prefetch_step(prefetch.step); |
There was a problem hiding this comment.
| ); | ||
| CATCH_REQUIRE(builder != nullptr); | ||
|
|
||
| auto get_prefetch = [&](svs_index_h index) { |
There was a problem hiding this comment.
Nit: same helper as get_prefetch in c_api_index_convert.cpp. Could it move to c_api_test_utils.h so both tests share it?
mihaic
left a comment
There was a problem hiding this comment.
Thanks for the suggestions. I believe I addressed them.
| // The source's search parameters carry prefetch settings estimated from the source | ||
| // data. Re-estimate them for the converted data, as a freshly built index would. | ||
| { | ||
| auto prefetch = svs::index::vamana::extensions::estimate_prefetch_parameters(data); | ||
| config.search_parameters.prefetch_lookahead(prefetch.lookahead) | ||
| .prefetch_step(prefetch.step); |
| ); | ||
| CATCH_REQUIRE(builder != nullptr); | ||
|
|
||
| auto get_prefetch = [&](svs_index_h index) { |
Also add prefetching getters that can be used for debugging and testing. Setters are left for future work.
0a5c219 to
584e374
Compare
| } | ||
|
|
||
| // Sequential threadpool for testing | ||
| // Read an index's prefetch settings as {lookahead, step}. |
There was a problem hiding this comment.
Minor change: looks like this function was inserted in between the sequential_tp_size and comment describing it - would be better to keep these together and put the additions in a separate block
ethanglaser
left a comment
There was a problem hiding this comment.
LGTM other than minor final comment
mihaic
left a comment
There was a problem hiding this comment.
I addressed the new comments. I also added a setter with the new svs_search_params_* API.
| } | ||
|
|
||
| // Sequential threadpool for testing | ||
| // Read an index's prefetch settings as {lookahead, step}. |
Also add prefetching getters and setter.