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

Performance minded with some bug fixes #6311

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft

Conversation

matteius
Copy link
Member

@matteius matteius commented Nov 6, 2024

The issue

Testing against the sentry requirements file profiling from a fresh virtualenv creation with no Pipfile/Pipfile.lock: https://raw.githubusercontent.com/getsentry/sentry/refs/heads/master/requirements-base.txt

Main branch:

image

This branch:

image

The fix

  • Reintroduce Pipfile caching -- carefully and with extra time checks
  • Refactor resolver methods to reduce context managers
  • cache the paths environment property.
  • Solve edge case with markers not be passed through when installing from CLI
  • Solve a different markers edge case
  • Eliminate some dead (unused) methods

The checklist

  • Associated issue
  • A news fragment in the news/ directory to describe this fix with the extension .bugfix.rst, .feature.rst, .behavior.rst, .doc.rst. .vendor.rst. or .trivial.rst (this will appear in the release changelog). Use semantic line breaks and name the file after the issue number or the PR #.

@matteius matteius changed the title Mostly performance minded but does fix a bug upgrading packages with … Performance minded with some bug fixes Nov 7, 2024
@matteius matteius marked this pull request as ready for review November 7, 2024 19:16
@matteius matteius requested a review from oz123 November 7, 2024 19:16
@matteius matteius marked this pull request as draft November 7, 2024 23:39
@@ -257,12 +257,6 @@ def python(self) -> str:

@cached_property
def sys_path(self) -> list[str]:
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

We made a terrible mistake in the python community remove docstrings in favor of annotations.

At list leave us with "The system path inside the environment" so we know that attribute is.

Also, if something is a list, one can consider calling it "sys_paths".

@@ -689,27 +750,6 @@ def _parse_pipfile(
# Fallback to toml parser, for large files.
return toml.loads(contents)

def _read_pyproject(self) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure why this was introduced, but is it OK to simply remove it?

def _release_file_lock(self, file_obj):
"""Release lock on an existing file object"""
if sys.platform == "win32":
import msvcrt
Copy link
Contributor

Choose a reason for hiding this comment

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

This import block is repeated in _acquire_file_lock and in _relase lock. Consider moving to the top.

packages = {
k: v
for k, v in self.parsed_pipfile.get(section, {}).items()
if is_vcs(v) or is_vcs(k)
Copy link
Contributor

Choose a reason for hiding this comment

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

How are VCS packages handeled now?

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.

2 participants