8000 Compute the SCCs of tests as well by elliottt · Pull Request #8899 · sorbet/sorbet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Compute the SCCs of tests as well #8899

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

elliottt
Copy link
Collaborator
@elliottt elliottt commented May 21, 2025

Currently, we ignore test dependencies when computing SCCs for packages. This is fine for our current needs, as we don't enforce strict dependencies or layering for test code, but this will change soon when we start refactoring the pipeline to operate on SCCs of packages.

This PR adds a second scc id to each package, testSccID. The new ID is the result of a separate run of Tarjan's algorithm over just test dependencies. While it's not used for anything currently, it will soon be used to emit a possible traversal order for packages when typechecking by SCC.

This change roughly doubles the time to compute SCCs, as it's now running the algorithm twice over the package graph.

Motivation

Prework for typechecking by package SCC.

Test plan

Existing tests.

@elliottt elliottt marked this pull request as ready for review May 21, 2025 17:34
@elliottt elliottt requested a review from a team as a code owner May 21, 2025 17:34
@elliottt elliottt requested review from froydnj and neilparikh and removed request for a team May 21, 2025 17:34
Copy link
Contributor
@froydnj froydnj left a comment

Choose a reason for hiding this comment

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

Good thing we made the SCC computation 2x faster a while back! :pats-self-on-back:

I think this change can land first, but will need to be modified after @aisamanra 's test import changes land?

Comment on lines +1758 to +1767 8000
switch (edgeType) {
case core::packages::ImportType::Normal: {
poppedPkgInfo.sccID_ = sccId;
break;
}
case core::packages::ImportType::Test: {
poppedPkgInfo.testSccID_ = sccId;
break;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make it so that we can use a pointer-to-member here, since the SCC we're modifying is constant over the entire tarjan run? I don't have super-strong opinions on the right way to pass that in at the top-level, but I think the right direction is somehow to link the edgeType to the pointer-to-member that we want? Maybe a method on PackageInfo that does that?

That might be Too Much C++, but my sense is that saving a branch here is valuable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I think that's a good idea. I'll have a look at how we might do that at the tarjan call site.

@elliottt
Copy link
Collaborator Author

I think this change can land first, but will need to be modified after @aisamanra 's test import changes land?

Yes... we'll need to run it a third time :lolsob:

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
0