Skip to content

Feature: Support level-aware prefetch in HNSW search #695

@yoonseok-kim

Description

@yoonseok-kim

Describe what you are looking for

In the current index_gt HNSW implementation, prefetching, metric evaluation, and predicate evaluation are executed at different stages depending on the search level.

Prefetching is currently used primarily as an optimization to read vector data for up to max_neighbors(m~2m) in advance. However, the current prefetch_t interface is not flexible enough to support the following use cases.

  • A user may want to enable prefetching only at upper levels, while disabling it on the base level.
  • When predicates are used, a user(me) may want to prefetch additional data required by the predicate, not only the vector values.
    • Note that predicates are evaluated only at the base level.

Currently, prefetch_t has the following signature.

struct prefetch_t {
    template <typename member_citerator_like_at>
    inline void operator()(member_citerator_like_at, member_citerator_like_at) const noexcept {}
};

To support the scenarios above, I would like to propose extending prefetch_t so that the level information can be passed into the prefetch stage.

struct prefetch_t {
    template <typename member_citerator_like_at>
    inline void operator()(member_citerator_like_at, member_citerator_like_at) const noexcept {}

    // new feature
    template <typename member_citerator_like_at>
    inline void operator()(member_citerator_like_at, member_citerator_like_at, level_t) const noexcept {}
};

I think this change is backward-compatible and can be implemented internally without altering existing behavior.

I’ve submitted a PR(#696) with the corresponding changes. I would appreciate any feedback or suggestions.

Can you contribute to the implementation?

  • I can contribute

Is your feature request specific to a certain interface?

C++ implementation

Contact Details

[email protected]

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions