Cache Pinecone Index connection in PineconeVectorStore#6589
Open
TimurRakhmatullin86 wants to merge 1 commit into
Open
Cache Pinecone Index connection in PineconeVectorStore#6589TimurRakhmatullin86 wants to merge 1 commit into
Index connection in PineconeVectorStore#6589TimurRakhmatullin86 wants to merge 1 commit into
Conversation
PineconeVectorStore called Pinecone.getIndexConnection(indexName) on every add, delete and similaritySearch. In the Pinecone client that performs a blocking control-plane describeIndex REST call on every invocation, adding a round trip of latency per data-plane operation and running into control-plane rate limits (429). The underlying gRPC connection is already cached in the client's static connectionsMap, so the repeated host resolution is pure overhead. Resolve the Index connection lazily once and reuse it (volatile field with double-checked locking); it is intentionally never closed by the store since Index.close() would remove the shared connection from the client's static map. Also remove dead code in similaritySearch (an unused QueryRequest builder and its import). Signed-off-by: Timur Rakhmatullin <174210871+TimurRakhmatullin86@users.noreply.github.com>
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.
PineconeVectorStorecalledPinecone.getIndexConnection(indexName)on everyadd,delete, andsimilaritySearchoperation. In the Pinecone Java client,getIndexConnectionperforms a blocking control-plane REST call (describeIndex) to resolve the index host on every invocation. Under bulk ingestion or query load this adds an extra HTTP round-trip of latency to each data-plane operation and runs into control-plane rate limits (HTTP 429).The repeated call is pure overhead: the underlying gRPC connection is already cached in the client's static
connectionsMap(computeIfAbsent), so the host resolved by everydescribeIndexcall after the first one is discarded.Changes:
Indexconnection lazily once and reuse it across operations (volatilefield with double-checked locking). If resolution fails, the field stays unset and the next operation retries.Index.close()closes the shared connection and removes it from the client's staticconnectionsMap, which would affect other consumers of the same index. The store did not close per-operation connections before this change either, so lifecycle behavior is unchanged.similaritySearch: aQueryRequestbuilder was constructed but never used (the query is issued viaqueryByVector), along with the now-unusedio.pinecone.proto.QueryRequestimport.PineconeVectorStoreTests(no network) verifying the connection is resolved exactly once across add/delete/search and lazily on first use.