Skip to content

Use lazy loading in error decorator, debugging config#481

Merged
jhamon merged 2 commits intorelease-candidate/2025-04from
jhamon/error-handling-lazy-load
May 15, 2025
Merged

Use lazy loading in error decorator, debugging config#481
jhamon merged 2 commits intorelease-candidate/2025-04from
jhamon/error-handling-lazy-load

Conversation

@jhamon
Copy link
Copy Markdown
Collaborator

@jhamon jhamon commented May 14, 2025

Problem

We want to continue improving our import and initialization times.

Solution

  • Refactor the @validate_and_convert_errors decorator to use lazy-loading of urllib3. We only need to load urllib3 in this decorator at the moment an exception has occurred.
  • Refactor pinecone.config.openapi_configuration.py to avoid loading the http module unless enabling debug logging. The default http log level is already 0 (disabled) so there's no need to set it in the default case.

Perf testing

poetry run python3 -X importtime -c "from pinecone import Pinecone; pc = Pinecone(api_key='foo')" 2> main.log

Comparing the importtime results before and after this change shows a reduction from 101ms to 65ms, a savings of 36ms which is about 36%.

Screenshot 2025-05-14 at 4 00 38 AM Screenshot 2025-05-14 at 4 50 58 AM

@jhamon jhamon changed the title Use lazy loading in error decorator Use lazy loading in error decorator, debugging config May 14, 2025
@jhamon jhamon marked this pull request as ready for review May 14, 2025 09:00
@jhamon jhamon changed the base branch from main to release-candidate/2025-04 May 14, 2025 09:01
@jhamon jhamon requested a review from austin-denoble May 14, 2025 09:51
@jhamon jhamon force-pushed the jhamon/error-handling-lazy-load branch from 8551a79 to 663a819 Compare May 14, 2025 20:25
@jhamon jhamon merged commit 4582a48 into release-candidate/2025-04 May 15, 2025
68 of 70 checks passed
@jhamon jhamon deleted the jhamon/error-handling-lazy-load branch May 15, 2025 18:06
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