Skip to content

Indirect loading Faiss index in warmup API when memory optimized search is enabled. #2939

@0ctopus13prime

Description

@0ctopus13prime

Description

When memory-optimized search is enabled, the warm-up operation performs a partial index load and determines the starting offset of each logical section within the index. This does not load anything from an underlying file or stream.
Because of this, users still incur the startup cost regardless of using the warm-up API.

Code reference: KNNIndexShard.java#L114-L118

In this proposal, we start with a simple approach that touches the entire file, indirectly delegating page loading to the kernel. With this mechanism, once an index has been warmed up, the cold start overhead will be reduced compared to when this optimization is absent.

Pseudocode:

if (directory is not FSDirectory) {
    // Do partial loading
    ...
    return
}

IndexInput input = ...;  // Get random accessor from FSDirectory
long fileSize = input.length();
for (long i = 0 ; i < fileSize ; i += 4096) {
    // Touch 1 byte from each page to trigger page fault, then kernel will load 4KB page from the file.
    input.readByte();
}

Metadata

Metadata

Labels

EnhancementsIncreases software capabilities beyond original client specifications

Type

No type

Projects

Status

3.x

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions