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

simplify SourceID Ord/Eq #14980

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

simplify SourceID Ord/Eq #14980

wants to merge 2 commits into from

Conversation

Eh2406
Copy link
Contributor

@Eh2406 Eh2406 commented Dec 24, 2024

What does this PR try to resolve?

This is a followup to #14800. Like that PR, this is a small incremental change that does not pull its own weight. If this PR is accepted, the next PR will unlock large performance wins. I am not posting them together because the logic of why this PR is correct is subtle and deserves to be discussed and reviewed without unrelated code changes.

How should we test and review this PR?

All tests pass on all commits. This should be reviewed one commit at a time.

Additional information

I pushed one commit at a time, so that CI can confirm that the assert (in the first commit) is never hit.

@rustbot
Copy link
Collaborator

rustbot commented Dec 24, 2024

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 24, 2024
@weihanglo
Copy link
Member

Potential risk:

If someone has two alternate registry hosted on github whose name has one of the weird languages where a < b does not imply a.to_lower() < b.to_lower() (we did this normalization in CanonicialUrl for only github.com domain), then the package order in the lockfile file could switch between different versions of Cargo.

Though this is pretty niche and I doubt it impacts any real world use case.

@Eh2406 Eh2406 marked this pull request as ready for review December 24, 2024 21:53
@weihanglo weihanglo added the T-cargo Team: Cargo label Dec 24, 2024
@weihanglo
Copy link
Member

@rfcbot fcp merge

I propose to the team to merge this. See the comment in 2a9527b for detailed explanation.

tl;dr

  • Cargo can never have two SourceIds with everything the same except for the url field, because when interning, we hash only kind, precise, and canonical_url, not url.
  • One of the risks we can think of is described in simplify SourceID Ord/Eq #14980
  • The other one might be a path dependency having a path ending with .git got chopped off, making the package order different in lockfile. I also think this is a weird use case we can ignore.

If there is any implication we're missing here, please call it out!

@rfcbot
Copy link
Collaborator

rfcbot commented Dec 24, 2024

Team member @weihanglo has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period An FCP proposal has started, but not yet signed off. disposition-merge FCP with intent to merge labels Dec 24, 2024
@Eh2406
Copy link
Contributor Author

Eh2406 commented Dec 24, 2024

Note that all of the risks identified so far involve the implications to ord and the performance benefits mostly relate to eq. If more risks are found, or the risks related to ord are to painful this PR can be updated to leave ord as is and instead do the comparable thing directly on eq. I prefer the code simplicity of eq delegating to ord, but opinions can legitimately vary.

@Rustin170506
Copy link
Member

If someone has two alternate registry hosted on github whose name has one of the weird languages where a < b does not imply a.to_lower() < b.to_lower()

May I ask, do you have a real example of this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge FCP with intent to merge proposed-final-comment-period An FCP proposal has started, but not yet signed off. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-cargo Team: Cargo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants