issue #547: wire jvector readRangeAsync to RemoteFileServiceClient for parallel FusedPQ IO#549
Merged
eolivelli merged 3 commits intoMay 13, 2026
Conversation
…r parallel FusedPQ IO - Pin CI jvector checkout to parallel-fusedpq-io branch while eolivelli/jvector#8 is unmerged - SegmentBlockCache: add AsyncBlockLoader FI + getBlockAsync() with single-flight semantics via ConcurrentHashMap<BlockKey, CF<ByteBuf>> inFlightAsync; hit/miss/load-time counters mirror the sync getBlock() path; correct refCnt=2 ownership on cache insertion - RemoteRandomAccessReader: override readRangeAsync(long, int) — does NOT touch position/ blockBuffer/bufferedBlockIndex; single-block fast path + multi-block allOf path with ByteBuf release-in-finally; fetchBlockFromRemoteAsync helper updates rfs_client_read_* stats; VectorSearchRequestContext hit/miss/readFileRange accounting preserved - PersistentVectorStore: add static volatile searchAsyncPipelineEnabled flag with setSearchAsyncPipelineEnabled() / isSearchAsyncPipelineEnabled() (default false) - VectorSegment.search(): call searcher.setAsyncPipelineEnabled() on every search so runtime toggle takes effect without discarding ThreadLocal-cached searchers - IndexingServerConfiguration: add PROPERTY_VECTOR_SEARCH_ASYNC_PIPELINE_ENABLED / SYSPROP_VECTOR_SEARCH_ASYNC_PIPELINE_ENABLED constants (default false) - IndexingServiceEngine: read new property and call setSearchAsyncPipelineEnabled() at IS startup - New tests: RemoteRandomAccessReaderAsyncTest (11 cases, PARANOID leak detector) + SegmentBlockCacheAsyncTest (7 cases, PARANOID leak detector)
Correctness fixes: - RemoteRandomAccessReader.fetchBlockFromRemoteAsync: convert null result (block-not-found) to a failed future with IOException, mirroring the null-check in the synchronous fetchBlockFromRemote; register the failure on clientReadLatency so the Grafana panels stay consistent - SegmentBlockCache.getBlockAsync: wrap loader.loadAsync() invocation in a try/catch (narrow RuntimeException) so a synchronously-throwing loader cannot leak the inFlightAsync entry (deadlocking future piggybackers). On synchronous throw: increment loadFailure, remove inFlightAsync slot, complete ourFuture exceptionally, return - RemoteRandomAccessReader.readRangeAsync multi-block path: capture wasCached + blockLen per block before dispatch, then record per-block cache-hit / cache-miss / readFileRange events on VectorSearchRequestContext after allOf completes — matches the single-block path contract documented in the readRangeAsync docstring - RemoteRandomAccessReader.readRangeAsync multi-block path: narrow catch (Exception e) to catch (RuntimeException e) with a justifying comment, per CLAUDE.md narrow-catch rule - Replace inline lambdas with this::fetchBlockFromRemoteAsync method references (readability) New tests (PARANOID Netty leak detector): - RemoteRandomAccessReaderAsyncTest#testMultiBlockPartialFailureReleasesAllBuffers: block 0 cache-hit + block 1 network-miss (server stopped, retries=0) — asserts future fails and no ByteBuf leaks - RemoteRandomAccessReaderAsyncTest#testMultiBlockUpdatesVectorSearchRequestContextStats: cross-block read with block 0 warmed asserts 1 hit + 1 miss + 2 readFileRange events recorded on VectorSearchRequestContext - SegmentBlockCacheAsyncTest#syncThrowingLoaderDoesNotDeadlockNextCaller: synchronously-throwing loader → future fails AND inFlightAsync slot is cleared so a subsequent getBlockAsync with a working loader invokes it - SegmentBlockCacheAsyncTest#concurrentSyncAndAsyncMissInsertSeesSameBytes: race a sync getBlock with an in-flight async load on the same key, assert byte equality and zero leaks (exercises the compute()-race path) Test hygiene: - SegmentBlockCacheAsyncTest: cache.clear() + cleanUp() in @after so PARANOID leak detection deterministically observes any leaked ByteBufs - RemoteRandomAccessReaderAsyncTest: handle null server in @after (for tests that stop the server mid-test); fix assertFalse → fail() for clarity in testReadRangeAsyncPastEofFails
The parallel-fusedpq-io PR branch was merged into main, so both CI workflows can go back to checking out main. Drops the transient ref: parallel-fusedpq-io pin (and the explanatory comment) introduced earlier in this PR.
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.
Fixes #547.
Changes
.github/workflows/ci.yml+kubernetes-tests.yml: pin jvector checkout toparallel-fusedpq-iobranch while eolivelli/jvector#8 is unmerged. Both workflows hadref: main; must track the PR branch to pick up the newreadRangeAsyncAPI. TODO: revert toref: mainonce the PR merges.SegmentBlockCache: addAsyncBlockLoaderfunctional interface +getBlockAsync(path, offset, length, AsyncBlockLoader)method. Uses aConcurrentHashMap<BlockKey, CompletableFuture<ByteBuf>> inFlightAsyncfor single-flight deduplication: concurrent misses for the same block share one loader call, each getting an independent retained slice. Hit path is an atomiccomputeIfPresentretain under the Caffeine map lock — the same pattern asgetBlock. Cache insertion usescompute()to handle the rare race with a concurrent syncgetBlockcall. RefCnt ownership rules (refCnt=2 on insert: cache ref + caller ref) are identical to the sync path.RemoteRandomAccessReader: overridereadRangeAsync(long, int)from jvector'sRandomAccessReader. Does NOT touchposition,blockBuffer, orbufferedBlockIndex(async reads bypass the sliding-window cursor). Single-block fast path calls onegetBlockAsync; multi-block path fires all covering blocks in parallel withallOf, assembling a heapByteBufferin the completion callback. AllByteBufslices are released in afinallyblock (both success and failure paths) so no off-heap memory escapes.fetchBlockFromRemoteAsynchelper mirrorsfetchBlockFromRemote— clamps length to avoid reading past EOF, updatesrfs_client_read_*counters andVectorSearchRequestContextaccounting.PersistentVectorStore: addstatic volatile boolean searchAsyncPipelineEnabledwithsetSearchAsyncPipelineEnabled()/isSearchAsyncPipelineEnabled(). Mirrors thesetStreamingCompactionEnabledpattern. Defaultfalseuntil a production profile confirms a net win.VectorSegment.search(): after getting or creating theThreadLocal-cachedGraphSearcher, callsearcher.setAsyncPipelineEnabled(PersistentVectorStore.searchAsyncPipelineEnabled)on every search invocation. Cheap field write; enables runtime toggle without discarding cached searcher instances.IndexingServerConfiguration: addPROPERTY_VECTOR_SEARCH_ASYNC_PIPELINE_ENABLED/SYSPROP_VECTOR_SEARCH_ASYNC_PIPELINE_ENABLEDconstants (defaultfalse).IndexingServiceEngine: read the new property at IS startup and callPersistentVectorStore.setSearchAsyncPipelineEnabled(); config key takes precedence over system property. Logs the resolved value.Tests
RemoteRandomAccessReaderAsyncTest(11 cases, Netty PARANOID leak detector):readRangeAsyncreturns identical bytes toseek+readFullyfor single-block, cross-block, three-block, and end-of-file ranges; position is invariant after async reads; 16 concurrent async reads alongside a synchronousreadFullyloop on the same reader instance produce correct bytes with no refcount exceptions; cache warm-up via sync path is visible to subsequent async reads; disabled-cache pass-through works.SegmentBlockCacheAsyncTest(7 cases, Netty PARANOID leak detector): pass-through on disabled cache; miss populates then next call is a hit; sync miss populates then async call is a hit; 16 concurrent async misses share exactly one loader call; each concurrent caller receives an independentByteBufslice; loader failure propagates to all waiting callers; multi-threaded async loads are byte-correct.🤖 Implemented by the
pr-workeragent.