Repository navigation
Refactor compaction for concurrent index - #487
razdoburdin wants to merge 12 commits into
Conversation
| /// @param task The task handle to free | ||
| /// @remarks A task keeps its index alive: the index is released only when the index | ||
| /// handle and all of its tasks are freed. | ||
| SVS_API void svs_task_free(svs_task_h task); |
There was a problem hiding this comment.
What will happen if user created a task, but not executed it?
There was a problem hiding this comment.
it's ok from correctness perspective. The task is deleted, but it's job remains undone.
There was a problem hiding this comment.
Hm, it does not look like reliable approach. Instead it looks like user can drop an uncompleted task at a middle of processing.
Considering use "commit-cancel" approach:
- Commit-and-release:
svs_task_complete()orsvs_task_commit()(rather thansvs_execute_task()) - complete/execute-till-finish the task and 'free' it. - Cancel-and-release:
svs_task_cancel()- can be used to mark a vector back to active (valid). Failed if external id is already reused for another vector - to be documented. - Drop-and-release
svs_task_drop()- just 'free' the task. Should be properly documented fordelete_pointtask explaining what will happen then.
There was a problem hiding this comment.
svs_execute_task -> svs_task_complete
svs_task_free -> svs_task_drop
|
Results from testing this PR (6d9a425) in valkey-search. valkey-search uses the C API with Setup:
Correctness: as a drop-in (no changes on the valkey-search side), the valkey-search unit suite (16/16), integration suite (1082 passed) and TSAN unit suite are clean. 1. Drop-in: cheaper compaction
Write throughput, recall@10 and memory are unchanged within run-to-run ranges. 2. Two-stage deleteHow we used it:
Maintenance runs on up to 96 threads; "off" is the drop-in. All runs are from the same day.
3. Compaction can be starved by the C API wrapper's lock
4. API notes
|
|
Follow-up: 245d1f8 fixes the compaction starvation we reported above. These are local runs on a 96-vCPU lab server, so they confirm the fix but don't predict cloud numbers: the lab host has more memory bandwidth than a cloud instance. The reference measurement will be on an AWS 16-vCPU instance with nearly all threads given to compaction, comparing peak latency for HNSW and LeanVec. We'll post those results here when they're done. Setup: same as above. Cohere 768-d, COSINE, 100K vectors, 64 clients overwriting while 8 search, 10 minutes, two runs per cell (ranges are min-max). Maintenance threads are scaled to the index size: at 100K, compaction uses up to 12 threads and consolidation up to 6. "Drains" are the background threads running
|
|
AWS reference run with #487 (245d1f8): peak latency under overwrite churn, HNSW against SVS. LeanVec isn't included. LVQ / LeanVec need the prebuilt SVS package, and no package with #487 exists yet. These columns are HNSW, SVS FP32 and SVS SQ8, all built from source with #487. We'll add LeanVec when a package with #487 is available. Setup:
Local runs (96-vCPU lab server, above) showed that running the per-delete repairs from |
|
AWS follow-up: the two-stage delete's per-delete consolidation, run in the background, on the same setup as the AWS run above (r8i.4xlarge server, 16 vCPU, Cohere 1M, 20 minutes of overwrites, "Repairs on" means:
This is a valkey-search prototype, not yet in a PR. "Off" is plain
LeanVec is still to come; it needs the prebuilt package with this PR. |
|
Follow-up from the Valkey Search community call on 2026-12-03 (notes): an exclusive compaction window should be about as short as a read or write (tens of milliseconds), with longer work time-sliced across windows and the per-pass setup cost known. This PR brings a compaction at 1M down to about 1 s on 16 vCPU with background repairs, so the remaining step is slicing it. Filed as #505: a C API call that compacts a bounded batch per call. |
The goal of this PR is reduction of compaction time for
concurrent::MutableVamanaIndex.Two approaches are applied:
repair_incomming_connectionstoconcurrent::MutableVamanaIndexand related orchestrators. The method takes a pointer to a response structure with internal ids and do consolidation (reparent of incoming connections) if the vector is soft-deleted (no-op for all other vectors).delete_entriesnow takes an optional pointer to a response structure, if the pointer isn't null it writes internal ids of the newly soft-deleted slots and compaction epoch.C-API changes:
svs_task_create_points_deletionreturns thesvs_task_h follow_up, allocate memory for it and write all required data, sofollow_uptask structure has all required information to finalize deletion.svs_task_completetakes thesvs_task_h taskand execute it. If the execution is successful, task is freed by this operation. If an error occurs, task is kept valid for resubmission on manual drop bysvs_task_drop.svs_task_dropfrees the tasks's memory without execution or rollback.So the 2-stage deletion pipeline looks like:
task = svs_task_create_points_deletion;
submit to background execution:
svs_task_complete(task);