Skip to content

Set prefetching based on the converted index - #490

Merged
mihaic merged 4 commits into
intel:mainfrom
mihaic:convert-prefetch
Dec 3, 2026
Merged

mihaic merged 4 commits into
intel:mainfrom
mihaic:convert-prefetch

Conversation

@mihaic

@mihaic mihaic commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Also add prefetching getters and setter.

@ethanglaser ethanglaser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looking good, just a few minor questions/suggestions

Comment thread bindings/c/src/dispatcher_vamana.cpp Outdated
Comment on lines +226 to +228
auto prefetch = svs::index::vamana::extensions::estimate_prefetch_parameters(data);
config.search_parameters.prefetch_lookahead(prefetch.lookahead)
.prefetch_step(prefetch.step);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +170 to +175
// 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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the logic in this block duplicates reset_performance_parameters() functionality defined here and here. Could this call experimental_reset_performance_parameters() on the assembled index instead?

Applies to this and the same block in dispatcher_vamana.cpp

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread bindings/c/tests/c_api_index.cpp Outdated
);
CATCH_REQUIRE(builder != nullptr);

auto get_prefetch = [&](svs_index_h index) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@mihaic mihaic left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestions. I believe I addressed them.

Comment on lines +170 to +175
// 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);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread bindings/c/tests/c_api_index.cpp Outdated
);
CATCH_REQUIRE(builder != nullptr);

auto get_prefetch = [&](svs_index_h index) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Also add prefetching getters that can be used for debugging and testing.

Setters are left for future work.
}

// Sequential threadpool for testing
// Read an index's prefetch settings as {lookahead, step}.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@ethanglaser ethanglaser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than minor final comment

Comment thread bindings/c/include/svs/c/svs_c.h Resolved

@mihaic mihaic left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addressed the new comments. I also added a setter with the new svs_search_params_* API.

Comment thread bindings/c/include/svs/c/svs_c.h Resolved
}

// Sequential threadpool for testing
// Read an index's prefetch settings as {lookahead, step}.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@rfsaliev rfsaliev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGFM

@mihaic
mihaic merged commit 9ebcc5f into intel:main Dec 3, 2026
6 of 7 checks passed
@mihaic
mihaic deleted the convert-prefetch branch December 3, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants