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

Fix algorithm for gathering Go build requests with coverage. #20030

Merged
merged 1 commit into from
Oct 15, 2023

Conversation

benjyw
Copy link
Contributor

@benjyw benjyw commented Oct 15, 2023

The previous algorithm did not check if a package had already been
traversed, which leads to exponential blowup of the queue.

Go doesn't support dependency cycles, so the previous algorithm
would converge eventually, but before it did so the queue could get
to sizes that were infinite in practice. This happened in a real-world
case.

@benjyw benjyw added the category:bugfix Bug fixes for released features label Oct 15, 2023
@benjyw benjyw requested a review from tdyas October 15, 2023 15:40
@benjyw benjyw linked an issue Oct 15, 2023 that may be closed by this pull request
@benjyw
Copy link
Contributor Author

benjyw commented Oct 15, 2023

To see this, consider that each iteration of the algorithm removes one package from the head of the queue, and adds all its direct deps to the end of the queue. Let's assume for simplicity that we have dependency chains of depth 8 and that each package has 10 direct deps (other than leaf packages which have no deps at all). We will get to a queue of ~10^8 elements.

@benjyw benjyw modified the milestones: 2.17.x, 2.16.x Oct 15, 2023
@benjyw benjyw merged commit 5ebdc41 into main Oct 15, 2023
24 checks passed
@benjyw benjyw deleted the benjyw_fix_algorithm_for_go_coverage branch October 15, 2023 17:38
WorkerPants pushed a commit that referenced this pull request Oct 15, 2023
The previous algorithm did not check if a package had already been
traversed, which leads to exponential blowup of the queue.

Go doesn't support dependency cycles, so the previous algorithm
would converge eventually, but before it did so the queue could get
to sizes that were infinite in practice. This happened in a real-world
case.
WorkerPants pushed a commit that referenced this pull request Oct 15, 2023
The previous algorithm did not check if a package had already been
traversed, which leads to exponential blowup of the queue.

Go doesn't support dependency cycles, so the previous algorithm
would converge eventually, but before it did so the queue could get
to sizes that were infinite in practice. This happened in a real-world
case.
WorkerPants pushed a commit that referenced this pull request Oct 15, 2023
The previous algorithm did not check if a package had already been
traversed, which leads to exponential blowup of the queue.

Go doesn't support dependency cycles, so the previous algorithm
would converge eventually, but before it did so the queue could get
to sizes that were infinite in practice. This happened in a real-world
case.
@WorkerPants
Copy link
Member

I tried to automatically cherry-pick this change back to each relevant milestone, so that it is available in those older releases of Pants.

✔️ 2.16.x

Successfully opened #20032.

✔️ 2.17.x

Successfully opened #20033.

✔️ 2.18.x

Successfully opened #20031.


Thanks again for your contributions!

🤖 Beep Boop here's my run link

benjyw added a commit that referenced this pull request Oct 16, 2023
…pick of #20030) (#20032)

The previous algorithm did not check if a package had already been
traversed, which leads to exponential blowup of the queue.

Go doesn't support dependency cycles, so the previous algorithm
would converge eventually, but before it did so the queue could get
to sizes that were infinite in practice. This happened in a real-world
case.

Co-authored-by: Benjy Weinberger <benjyw@gmail.com>
benjyw added a commit that referenced this pull request Oct 16, 2023
…pick of #20030) (#20033)

The previous algorithm did not check if a package had already been
traversed, which leads to exponential blowup of the queue.

Go doesn't support dependency cycles, so the previous algorithm
would converge eventually, but before it did so the queue could get
to sizes that were infinite in practice. This happened in a real-world
case.

Co-authored-by: Benjy Weinberger <benjyw@gmail.com>
benjyw added a commit that referenced this pull request Oct 16, 2023
…pick of #20030) (#20031)

The previous algorithm did not check if a package had already been
traversed, which leads to exponential blowup of the queue.

Go doesn't support dependency cycles, so the previous algorithm
would converge eventually, but before it did so the queue could get
to sizes that were infinite in practice. This happened in a real-world
case.

Co-authored-by: Benjy Weinberger <benjyw@gmail.com>
benjyw added a commit that referenced this pull request Dec 24, 2023
The previous algorithm did not check if a package had already been
traversed, which leads to exponential blowup of the queue.

Go doesn't support dependency cycles, so the previous algorithm
would converge eventually, but before it did so the queue could get
to sizes that were infinite in practice. This happened in a real-world
case.

This is an identical fix to the one in #20030, which was for
coverage build requests. These are the only two places in the go
backend (that I can find) where a transitive walk like this is done.
benjyw added a commit that referenced this pull request Dec 24, 2023
The previous algorithm did not check if a package had already been
traversed, which can lead to exponential blowup of the queue.

This is an identical fix to the one in #20030, which was for coverage
build requests. These are the only two places in the go backend 
(that I can find) where a transitive walk like this is done.

Unlike #20030 this one is not known to have caused a problem for any
users in practice.
alonsodomin pushed a commit to alonsodomin/pants that referenced this pull request Dec 28, 2023
The previous algorithm did not check if a package had already been
traversed, which can lead to exponential blowup of the queue.

This is an identical fix to the one in pantsbuild#20030, which was for coverage
build requests. These are the only two places in the go backend 
(that I can find) where a transitive walk like this is done.

Unlike pantsbuild#20030 this one is not known to have caused a problem for any
users in practice.
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.

go test hangs in endless loop
3 participants