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

Keep sessions around between each ConanRequester #17455

Merged
merged 12 commits into from
Jan 9, 2025

Conversation

AbrilRBS
Copy link
Member

@AbrilRBS AbrilRBS commented Dec 12, 2024

Changelog: Feature: Cache HTTP request sessions between API calls
Docs: Omit

Avoid creating a new session for each ConanRequester instance, this helps a lot with performance, as it avoids the overhead duplicate handshakes

I get an additional 40% speedup on top of #17449

Avoid creating a new session for each ConanRequester instance, this
helps a lot with performance, as it avoids the overhead duplicate handshakes
@AbrilRBS AbrilRBS requested a review from memsharded December 12, 2024 13:27
@AbrilRBS AbrilRBS marked this pull request as draft December 12, 2024 13:29
@AbrilRBS AbrilRBS marked this pull request as ready for review December 23, 2024 09:13
conan/test/utils/tools.py Show resolved Hide resolved
conan/api/conan_api.py Outdated Show resolved Hide resolved
@AbrilRBS AbrilRBS added this to the 2.12.0 milestone Dec 23, 2024
Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks much better than the previous approach

conan/internal/conan_app.py Outdated Show resolved Hide resolved
conan/test/utils/tools.py Show resolved Hide resolved
conans/client/rest/conan_requester.py Outdated Show resolved Hide resolved
Copy link
Contributor

@franramirez688 franramirez688 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow! This looks amazing! Great job @AbrilRBS !!

Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking very good!

@@ -31,6 +32,8 @@ def __init__(self, conan_api):
self.conan_api = conan_api
self._home_folder = conan_api.home_folder
self._remotes_file = HomePaths(self._home_folder).remotes_path
# Wraps an http_requester to inject proxies, certs, etc
self._requester = ConanRequester(self.conan_api.config.global_conf, self.conan_api.cache_folder)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to design, implement and document properly the "invalidating" and reloading of global.conf, like the requester will not get new conf after a config install. I think this is perfectly good as default, but the "invalidation" should also be doable and documented. I'll create a ticket for this later.

self._url_creds = _SourceURLCredentials(cache_folder)
self._max_retries = config.get("core.net.http:max_retries", default=2, check_type=int)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _max_retries is now legacy?

@AbrilRBS
Copy link
Member Author

AbrilRBS commented Jan 8, 2025

After internal testing on Conan Center Index, this has reduced some cases of build-order calculations from 45 mins to 10.

@memsharded memsharded merged commit cb06fe0 into conan-io:develop2 Jan 9, 2025
33 checks passed
@AbrilRBS AbrilRBS deleted the ar/keep-sessions-around branch January 9, 2025 14:24
memsharded pushed a commit to memsharded/conan that referenced this pull request Jan 15, 2025
* Keep sessions around between each ConanRequester

Avoid creating a new session for each ConanRequester instance, this
helps a lot with performance, as it avoids the overhead duplicate handshakes

* Patch new cached value on ConanRequester tests

* Modify adapter as needed

* Fix tests

* Name

* Update conans/client/rest/conan_requester.py

* Refactor requester tests

* Reinit is not part of this PR

* Refactor request usage out of app

* Make max_retries a local variable
memsharded added a commit that referenced this pull request Jan 21, 2025
* extra patches path

* Update conan/tools/files/patches.py

Co-authored-by: Andrey Filipenkov <kambaladecapitator@gmail.com>

* fix docstring of Environment.vars() (#17521)

fix docstring of vars()

* GnuToolchain's make_args handle empty values correctly (#17532)

test

* Change replace_in_file to return True on success (#17531)

- was inconsistent before: returned False if the
  pattern was not found (with strict off), otherwise None

* upgrade bottle version (#17534)

* better traces and msgs (#17517)

* better traces and msgs

* fix tests

* Feature/workspace api (#17501)

* working in workspace_api

* fixed loader + run() error

* update webtest testing version (#17537)

* proposing new --format=<format> --out-file=<file.ext> feature (#17507)

* proposing new --format=file.ext feature

* change approach and some simplifications

* remove unused

* minor changes

* minor changes

* simplify a bit

* fix format

* minor changes

* fix

* move colorama deinit/reinit

* add out-file only if formatters

* revert

* wip

* do not deinit/reinit if not tty

* clean import

* minor changes

---------

Co-authored-by: czoido <mrgalleta@gmail.com>

* Test/remote login (#17552)

* new test for remote_login

* unittest->pytest

* Keep sessions around between each ConanRequester (#17455)

* Keep sessions around between each ConanRequester

Avoid creating a new session for each ConanRequester instance, this
helps a lot with performance, as it avoids the overhead duplicate handshakes

* Patch new cached value on ConanRequester tests

* Modify adapter as needed

* Fix tests

* Name

* Update conans/client/rest/conan_requester.py

* Refactor requester tests

* Reinit is not part of this PR

* Refactor request usage out of app

* Make max_retries a local variable

* Add rest of posible `ConanBasicApp` usages (#17555)

Add rest of posible ConanBasicApp usages

* Improve typing information in remove sub API (#17564)

As the API actually accepts the remote to be `None`, this should also be
reflected in the type information in order to support users.

* small refactor to PkgConfigDeps (#17568)

* Updated to use maxsplit=1 (#17571)

* Updated to use maxsplit=1

* Add tests, unquote paths with spaces

---------

Co-authored-by: Abril Rincón Blanco <git@rinconblanco.es>

* refactor moving model conans->conan (#17572)

* refactor moving model conans->conan

* fix tests

* allow non trim_conandata

* removed print

---------

Co-authored-by: Andrey Filipenkov <kambaladecapitator@gmail.com>
Co-authored-by: Andrey Filipenkov <decapitator@ukr.net>
Co-authored-by: Ernesto de Gracia Herranz <ernestodgh@jfrog.com>
Co-authored-by: mrbean-bremen <mrbean-bremen@users.noreply.github.com>
Co-authored-by: czoido <mrgalleta@gmail.com>
Co-authored-by: Abril Rincón Blanco <rubenrb@jfrog.com>
Co-authored-by: Martin Lambertsen <github@lambertsen.one>
Co-authored-by: maitrey <maitreymishra23@gmail.com>
Co-authored-by: Abril Rincón Blanco <git@rinconblanco.es>
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.

3 participants