Repository navigation
refactor: remove dead code and redundant state in HNSW, IVF and dispatch - #186
Merged
Merged
Conversation
add_point is only called by construct, which passes distinct labels within its validated capacity, so the 65536 per-label mutexes protected nothing and the duplicate-label and capacity throws could not fire. Graph traversal guards had diverged (> max_elements_ vs >= num_stored_points_) and were unreachable because construct and add publish IDs before linking and load validates every neighbor; assert the invariant instead. Remove the first-element else branches, whose stores were always overwritten by the promotion that follows.
ready_ is set only after construct or load has created the initializer, rotator and cluster storage, so the extra conditions in the five readiness checks were redundant; reserve already omitted two of them. Messages are unchanged. Assert the internal cluster-size invariant and drop the unreachable metric branch in search; the metric is validated on construction and load.
Remove the unused RABITQ_RESOLVE2 macro and two-argument resolve_kernel, fold the single-use excode_dispatch.hpp into dispatch.cpp with internal linkage, remove the test-only one_bit_code in favor of one_bit_code_with_factor, and drop two redundant void casts in LloydKMeans.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Remove dead code and redundant state. The removed code either has no callers or can never trigger, so behavior is unchanged. No public API, Python API or saved-index format changes. The private layout of
HierarchicalNSWchanges; its source API does not.label_op_locks_: 65536 mutexes allocated on every construct and load that protected nothing.add_pointis only called byconstruct, which passes distinct labels within its validated capacity.add_pointinto asserts, sinceconstructalready guarantees both.assert(cand < num_stored_points_). The guards had diverged (> max_elements_vs.>= num_stored_points_) and could not fire:constructandaddpublish IDs before linking, andloadvalidates every neighbor.elsebranches whose stores were always overwritten by the promotion that follows.!ready_; the error messages are unchanged.ready_is set only afterconstructorloadcreates the initializer, rotator and cluster storage, andreservealready omitted two of the extra conditions.quantize_cluster.search; the metric is validated on construction and load.RABITQ_RESOLVE2macro and the two-argumentresolve_kernel.src/simd/excode_dispatch.hppintodispatch.cppwith internal linkage.one_bit::one_bit_code. The sign-convention test now usesone_bit_code_with_factor, which is the function production code calls.static_cast<void>(num_workers)inLloydKMeanswhere the variable is also used outside OpenMP pragmas.Kept on purpose:
hnsw::detail::search_knn: a documented compatibility adapter and an exported symbol.num_workerscasts: those variables appear only in pragmas, so the casts prevent unused-variable warnings when pragmas are ignored.Testing
RABITQ_ENABLE_NATIVE_OPTIMIZATION=OFF,--no-tests=error) on an AVX-512 Linux host:check-format.sh, fullcheck-tidy.sh build-tidyandgit diff --checkpassed.