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

Improve memoization of interpreter constraints, Python parsing, and request classes #16141

Merged
merged 3 commits into from Jul 12, 2022

Conversation

stuhood
Copy link
Sponsor Member

@stuhood stuhood commented Jul 12, 2022

Profiling showed that:

  1. Requirement.parse and InterpreterConstraint.merge_* were taking up a significant fraction of time even with singular requirements (~2%).
  2. AllAssetTargetsRequest did not have stable equality due to not being marked as a @dataclass, and so find_all_assets was not being memoized (~11%).
  3. Repeatedly loading and creating a Digest for the dependency_parser.py script took a noticeable amount of time (~6%).

Fixing these represents a ~19% performance improvement for ./pants --no-pantsd --changed-diffspec=fcaac98402..2a300002f0 --changed-dependees=transitive list, which brings 2.12.x/2.13.x roughly back in line with 2.11.x.

…ging for a single input.

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@stuhood
Copy link
Sponsor Member Author

stuhood commented Jul 12, 2022

Commits are useful to review independently.

@Eric-Arellano
Copy link
Contributor

Is this specifically meant to address #16122? As in, we don't need to investigate the code paths in that issue more?

@stuhood stuhood enabled auto-merge (squash) July 12, 2022 15:57
@stuhood
Copy link
Sponsor Member Author

stuhood commented Jul 12, 2022

Is this specifically meant to address #16122? As in, we don't need to investigate the code paths in that issue more?

As commented there, I wasn't able to reproduce a difference on the reported scale, so I'm going to leave that one open until we can get a repro.

@stuhood stuhood merged commit ec61fa7 into pantsbuild:main Jul 12, 2022
@stuhood stuhood deleted the stuhood/2.13-profiling branch July 12, 2022 17:38
stuhood added a commit to stuhood/pants that referenced this pull request Jul 12, 2022
…equest classes (pantsbuild#16141)

Profiling showed that:
1. `Requirement.parse` and `InterpreterConstraint.merge_*` were taking up a significant fraction of time even with singular requirements (~2%).
2. `AllAssetTargetsRequest` did not have stable equality due to not being marked as a `@dataclass`, and so `find_all_assets` was not being memoized (~11%).
3. Repeatedly loading and creating a `Digest` for the `dependency_parser.py` script took a noticeable amount of time (~6%).

Fixing these represents a ~19% performance improvement for `./pants --no-pantsd --changed-diffspec=fcaac98402..2a30000 --changed-dependees=transitive list`, which brings `2.12.x`/`2.13.x` roughly back in line with `2.11.x`.

[ci skip-rust]

[ci skip-build-wheels]
stuhood added a commit to stuhood/pants that referenced this pull request Jul 12, 2022
…equest classes (pantsbuild#16141)

Profiling showed that:
1. `Requirement.parse` and `InterpreterConstraint.merge_*` were taking up a significant fraction of time even with singular requirements (~2%).
2. `AllAssetTargetsRequest` did not have stable equality due to not being marked as a `@dataclass`, and so `find_all_assets` was not being memoized (~11%).
3. Repeatedly loading and creating a `Digest` for the `dependency_parser.py` script took a noticeable amount of time (~6%).

Fixing these represents a ~19% performance improvement for `./pants --no-pantsd --changed-diffspec=fcaac98402..2a30000 --changed-dependees=transitive list`, which brings `2.12.x`/`2.13.x` roughly back in line with `2.11.x`.
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
stuhood added a commit that referenced this pull request Jul 12, 2022
…equest classes (Cherry-pick of #16141) (#16153)

Profiling showed that:
1. `Requirement.parse` and `InterpreterConstraint.merge_*` were taking up a significant fraction of time even with singular requirements (~2%).
2. `AllAssetTargetsRequest` did not have stable equality due to not being marked as a `@dataclass`, and so `find_all_assets` was not being memoized (~11%).
3. Repeatedly loading and creating a `Digest` for the `dependency_parser.py` script took a noticeable amount of time (~6%).

Fixing these represents a ~19% performance improvement for `./pants --no-pantsd --changed-diffspec=fcaac98402..2a30000 --changed-dependees=transitive list`, which brings `2.12.x`/`2.13.x` roughly back in line with `2.11.x`.

[ci skip-rust]
[ci skip-build-wheels]
stuhood added a commit that referenced this pull request Jul 12, 2022
…equest classes (Cherry-pick of #16141) (#16154)

Profiling showed that:
1. `Requirement.parse` and `InterpreterConstraint.merge_*` were taking up a significant fraction of time even with singular requirements (~2%).
2. `AllAssetTargetsRequest` did not have stable equality due to not being marked as a `@dataclass`, and so `find_all_assets` was not being memoized (~11%).
3. Repeatedly loading and creating a `Digest` for the `dependency_parser.py` script took a noticeable amount of time (~6%).

Fixing these represents a ~19% performance improvement for `./pants --no-pantsd --changed-diffspec=fcaac98402..2a30000 --changed-dependees=transitive list`, which brings `2.12.x`/`2.13.x` roughly back in line with `2.11.x`.

[ci skip-rust]
[ci skip-build-wheels]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:bugfix Bug fixes for released features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants