[Bug] Warm-up does not pick up .veb file for MOS.#3228
[Bug] Warm-up does not pick up .veb file for MOS.#32280ctopus13prime wants to merge 2 commits intoopensearch-project:mainfrom
Conversation
Signed-off-by: Dooyong Kim <kdooyong@amazon.com>
253dc6e to
09c4020
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3228 +/- ##
============================================
- Coverage 83.18% 83.15% -0.04%
- Complexity 4215 4232 +17
============================================
Files 453 455 +2
Lines 15455 15468 +13
Branches 1972 1976 +4
============================================
+ Hits 12857 12863 +6
- Misses 1805 1808 +3
- Partials 793 797 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @0ctopus13prime, I took a look at this and I believe there is a better way to revamp warmup API. While warmup can fundamentally be achieved with search the low level reality for this specific case is different, there is completely separate logic for warmup which calls for separation of concerns and not break the single-responsibility principle. The intent of moving warmup to reader seems spot on here. At the same time I want to propose a more extensible way to implement this and make it generic
This might be missing some edge cases, but should cover most of the cases. Let me know your thoughts on this |
|
Hi @shatejas |
Signed-off-by: Dooyong Kim <kdooyong@amazon.com>
09c4020 to
1fd7b0b
Compare
Description
Previously, warmup was handled externally by MemoryOptimizedSearchWarmup — it manually located engine files on disk, opened them via the Directory, and page-faulted bytes by seeking every 4096 bytes. Full-precision vectors were loaded separately by iterating FloatVectorValues through the LeafReader. The codec readers themselves had no warmup awareness; they threw a WarmupInitializationException when they received a null target vector during warmup, which the caller silently caught.
This PR pushes warmup responsibility down into the codec readers and the VectorSearcher implementations where the actual index structures live.
The key changes:
Introduced WarmUpCollector, a sentinel KnnCollector singleton. Instead of passing null as the target vector and catching exceptions, warmup is now signaled cleanly by passing WarmUpCollector.INSTANCE through the existing search() API. Codec readers detect it via WarmUpCollector.isWarmUpRequest() and branch into warmup logic.
Added warmUp() to the VectorSearcher interface. FaissMemoryOptimizedSearcher.warmUp() clones the IndexInput and reads every byte of the FAISS graph, then warms up flat vectors based on encoding type (float or byte). This replaces the old external byte-skipping approach with a complete sequential read that actually touches every page.
Codec readers now own the warmup orchestration. NativeEngines990KnnVectorsReader delegates to VectorSearcher.warmUp() and additionally warms up .vec files for qframe fields via WarmupUtil.readAll(). Faiss1040ScalarQuantizedKnnVectorsReader delegates to VectorSearcher.warmUp() for the .faiss file, then explicitly iterates full-precision vectors to warm up .veb and .vec.
MemoryOptimizedSearchWarmup was simplified — it no longer touches the Directory or reads files directly. It just identifies memory-optimized fields and calls search() with the WarmUpCollector sentinel, letting each codec reader handle the rest.
Removed WarmupInitializationException and the null-target-vector hack from FaissMemoryOptimizedSearcher.
Added WarmupUtil as a shared utility for reading IndexInput, FloatVectorValues, and ByteVectorValues into the page cache, with an optimization that reads directly from the backing IndexInput slice when the values implement HasIndexSlice.
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
N/A
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.