[C API] Add cancellation-poll callback to `svs_search_params`
I maintainer di solito rispondono entro 5 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
Direzione di ricerca
Start by locating the svs_search_params and svs_index_search_topk declarations and implementation, then inspect the existing tests under bindings/c/tests/. Define the callback and cancellation error behavior at the API boundary, document the polling cadence in the header, and add tests for cancellation before start, cancellation mid-search, and no cancellation. Finish by checking the null-callback overhead against the stated benchmark.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
svs_index_search_topk at pin 5717f6855a73a9ab7524748e2a10a57ed865737d
takes an svs_search_params_h but exposes no way for the caller to
interrupt a running search. The search completes fully regardless of
whether the caller wants to abandon it. This ask adds an optional
is_cancelled_fn(userdata) -> bool callback to svs_search_params;
SVS polls it at appropriate points inside the search loop and returns
partial results plus an SVS_ERROR_CANCELLED code when the callback
returns true.
Motivation
valkey-search integrates SVS as ALGORITHM SVS_VAMANA and must honour
client-side query timeouts and shutdown signals. Its existing HNSW path
polls a cancel::Token on every visited node via
hnswlib::BaseCancellationFunctor (see
valkey-io/valkey-search:src/indexes/vector_hnsw.cc:322-329), so a
canceled query returns promptly with absl::CancelledError and the
client sees -ERR Search timed out. Without an SVS equivalent, SVS
searches on large indexes run to completion after the timeout fires
and the module returns the (now-stale) results to a client that has
long since disconnected. Two user-facing consequences:
- Client timeouts don't fire mid-search. On large indexes with modest
search_window_sizethis can stretch a query well past the
client's configured timeout. - Server shutdown is delayed by the tail of any in-flight search.
Proposed change
Add a callback field to svs_search_params. Version-gate via
SVS_C_API_VERSION so callers can compile against either the current
or the extended layout.
typedef bool (*svs_is_cancelled_fn)(void* userdata);
SVS_API bool svs_search_params_set_cancel_callback(
svs_search_params_h params,
svs_is_cancelled_fn fn, /* NULL to disable */
void* userdata, /* opaque, passed to fn */
svs_error_h out_err);
Semantics:
- If a callback is set and returns
trueduring a search, SVS aborts
the current search and returns whatever candidates it has already
collected insvs_search_results_t. The out-error carries
SVS_ERROR_CANCELLEDso the caller can distinguish a cancel from
an I/O or state error. - If no callback is set (default), current behavior is preserved.
- The callback may be invoked from any thread SVS uses for the
search (in valkey-search's case, the calling reader thread with
our customsize()=1threadpool). It must be reentrant-safe. - SVS should poll the callback at a reasonable granularity --
matching HNSW's per-visited-node poll would be ideal but per-batch
is acceptable if per-node adds measurable overhead. Document the
cadence.
Acceptance criteria
svs_search_params_set_cancel_callbacksets a callback that SVS
polls duringsvs_index_search_topk.- On callback returning
true, the call returns non-zero
results.n_results(partial) when at least one candidate was
found, or zero if none were found;svs_error_get_code(err)
returnsSVS_ERROR_CANCELLED. - On callback returning
falsethroughout, results are identical
to the non-cancelable path. - On callback being NULL / unset, behavior identical to today's
API. - Poll cadence documented in the header (per-node or per-batch).
- Unit tests in
bindings/c/tests/cover: cancel-before-start
(returns empty + cancelled code), cancel-mid-search (returns
partial + cancelled code), no-cancel (identical to baseline). - Cost benchmark: null-callback overhead vs. baseline is
below 1% p50 on the standardbindings/c/testsrecall dataset
at k=10.
Non-goals
- Preemptive thread cancellation. Cooperative poll is sufficient.
- Cancellation on
svs_index_build_dynamic,svs_index_load_dynamic,
orsvs_index_dynamic_add_points. Search is the load-bearing path;
the mutating ops are short enough that adding cancellation is not
worth the API surface.
- Lingua principale
- C++
- Stelle
- 241
- Fork
- 48
- Merge medio
- 4g 21h
- PR unite (30g)
- 11
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di intel/ScalableVectorSearch
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
intel/ScalableVectorSearch#356 ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
intel/ScalableVectorSearch#469 ·
I maintainer di solito rispondono entro 5 giorni
-
Add CI test for C API on ARMApertaenhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 32/100
intel/ScalableVectorSearch#460 ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
intel/ScalableVectorSearch#438 ·
I maintainer di solito rispondono entro 5 giorni
-
CI: tier the test matrix into PR / main / nightly to cut Actions minutesForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 32/100
intel/ScalableVectorSearch#432 · 1 commento ·
I maintainer di solito rispondono entro 5 giorni
Tutte le issue di intel/ScalableVectorSearch
Issue simili
-
runtime: lf_f128_mod is documented as fmodq (truncating) but implements floor-based modulo; unusedApertainternal correctness low priority rt_lib
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 87/100
-
PriorityNotificationQueue::wakeUpAll() loses the wake-up for a thread that is not waiting yetForse già presa @matejk l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
pocoproject/poco#5674 ·
I maintainer di solito rispondono entro 2 giorni
-
bug docs GUI
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
sonic-pi-net/sonic-pi#3609 ·
-
Unreachable code warningApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
SanderMertens/flecs#2395 ·
I maintainer di solito rispondono entro 1 giorno