Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose connection_pool_maxsize on Index and add docstrings #415

Merged
merged 2 commits into from
Nov 13, 2024

Conversation

jhamon
Copy link
Collaborator

@jhamon jhamon commented Nov 13, 2024

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

  • New feature (non-breaking change which adds functionality)

Test Plan

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

@jhamon jhamon changed the title Expose connection_pool_maxsize and add docstrings Expose connection_pool_maxsize on Index and add docstrings Nov 13, 2024
@jhamon jhamon marked this pull request as ready for review November 13, 2024 14:10
@jhamon jhamon requested a review from Noam-Barbiru November 13, 2024 14:10
@jhamon jhamon merged commit eade7dd into main Nov 13, 2024
83 of 85 checks passed
@jhamon jhamon deleted the jhamon/expose-maxsize branch November 13, 2024 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant