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

Include non-redundant separators in Hash for Path #127255

Closed
wants to merge 3 commits into from

Conversation

zanieb
Copy link
Contributor

@zanieb zanieb commented Jul 3, 2024

Closes #127254, please see the issue for the details as I cover a lot there.

I'm not confident this is the clearest way to fix this, I'd appreciate some feedback.

@rustbot
Copy link
Collaborator

rustbot commented Jul 3, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Nilstrieb (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 3, 2024
@zanieb
Copy link
Contributor Author

zanieb commented Jul 3, 2024

cc @the8472 as I believe the regression was from your commit and you look quite active still.

@rust-log-analyzer

This comment has been minimized.

@zanieb
Copy link
Contributor Author

zanieb commented Jul 3, 2024

Ah I can reproduce that test failure locally — I was only testing test_compare. I'll investigate a fix.

@zanieb zanieb marked this pull request as draft July 3, 2024 02:26
Comment on lines +1597 to +1602
tc!("foo/bar", "foobar",
eq: false,
starts_with: false,
ends_with: false,
relative_from: None
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the test case reported in the issue.

@the8472 the8472 assigned the8472 and unassigned Noratrieb Jul 3, 2024
@the8472
Copy link
Member

the8472 commented Jul 3, 2024

I'll take a look and will have to run some benchmarks to see the perf impact of this change, since that loop is fairly sensitive.

@the8472
Copy link
Member

the8472 commented Jul 3, 2024

Yeah, this regresses hashset performance

this PR: 
    path::tests::bench_path_hashset                   342.01/iter    +/- 8.37
    path::tests::bench_path_hashset_miss              139.03/iter    +/- 8.95

master:
    path::tests::bench_path_hashset                   244.21/iter    +/- 6.28
    path::tests::bench_path_hashset_miss              100.68/iter    +/- 9.11

I'll see if I can find an alternative that satisfies the added tests.

@the8472
Copy link
Member

the8472 commented Jul 3, 2024

I took your tests and added a more lightweight fix in #127297

@zanieb
Copy link
Contributor Author

zanieb commented Jul 3, 2024

#127297 seems like a much better approach

@zanieb zanieb closed this Jul 3, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 7, 2024
Improve std::Path's Hash quality by avoiding prefix collisions

This adds a bit rotation to the already existing state so that the same sequence of characters chunked at different offsets into separate path components results in different hashes.

The tests are from rust-lang#127255

Closes rust-lang#127254
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jul 7, 2024
Rollup merge of rust-lang#127297 - the8472:path-new-hash, r=Nilstrieb

Improve std::Path's Hash quality by avoiding prefix collisions

This adds a bit rotation to the already existing state so that the same sequence of characters chunked at different offsets into separate path components results in different hashes.

The tests are from rust-lang#127255

Closes rust-lang#127254
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hash implementation for Path ignores path separators
5 participants