pinecone-io / pinecone-python-client

The Pinecone Python client
https://www.pinecone.io/docs
Apache License 2.0
309 stars 80 forks source link

Expose connection_pool_maxsize on Index and add docstrings #415

Closed jhamon closed 1 week ago

jhamon commented 1 week ago

Problem

To explore the impact on performance, I want to expose a configuration kwarg for connection_pool_maxsize on Index.

Solution

This connection_pool_maxsize value is passed in to urllib3.PoolManager as maxsize. This param controls how many connections are cached for a given host. If we are using a large number of threads to increase parallelism but this maxsize value is relatively small, we can end up taking unnecessary overhead to establish and discard connections beyond the maxsize that are being cached.

By default connection_pool_maxsize is set to multiprocessing.cpu_count() * 5. In Google colab, cpu count is only 2 so this is fairly limiting.

Usage

from pinecone import Pinecone

pc = Pinecone(api_key='key')
index = pc.Index(
  host="jen1024-dojoi3u.svc.apw5-4e34-81fa.pinecone.io",
  pool_threads=25, 
  connection_pool_maxsize=25
)

Type of Change

Test Plan

I ran some local performance tests and saw this does have an impact to performance.