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: remove unnecessary lockfile header comparison #8622

Closed
wants to merge 3 commits into from

Conversation

weihanglo
Copy link
Member

@weihanglo weihanglo commented Aug 16, 2020

Closes #8610

What

#6548 introduced generated headers, which makes fn are_equal_lockfiles() always return false if a lockfile contains the header. This PR let the equality check 1) skip lines of header and 2) remove unnecessary str::to_string and String::replace allocations by using iterators to solve the minor regression bug.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Eh2406 (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 16, 2020
@Eh2406
Copy link
Contributor

Eh2406 commented Aug 17, 2020

On one hand we made the change intentionally, knowing that it may break some workflows. On the other hand making the diffing algoram ignore comment lines, feels small and reasonable. I put it on the Cargo Teams agenda for the next meeting.

@Eh2406
Copy link
Contributor

Eh2406 commented Aug 21, 2020

We talked about this in the Cargo Team meeting. Generally there are plans in the works to make the way we upgrade the lockfile more consistent. With the larger plan to be more consistently updating to newer formats, we don't want to take this incremental step in the other direction. Especially as #8554 will mean that changes to the lockfile will update to v2, and this small patch will not be enough to fix your workflow.

Thank you for the contribution, and sorry for the inconvenience.

@Eh2406 Eh2406 closed this Aug 21, 2020
@weihanglo weihanglo deleted the fix/lockfile-header branch August 21, 2020 15:04
@weihanglo
Copy link
Member Author

Totally understand your points. It is reasonable to update the format steadily.

Just another tiny question, should I send another PR to remove aforementioned unnecessary allocations? Sometimes Cargo.lock goes too large to ignore the cloning cost

@Eh2406
Copy link
Contributor

Eh2406 commented Aug 22, 2020

I have not seen the clones show up in profiling, but I am happy to see them go. Open to a new PR.

bors added a commit that referenced this pull request Aug 23, 2020
fix: remove unnecessary allocations

Remove unnecessary `str::to_string` and `str::replace` allocations by using iterators. This PR is almost identical to #8622 except it does not skip the generated header.

Sorry that I did not profile the changes by myself. Seems that valgrind does not support macOS 10.15.6, I have not idea how to profile cargo subcommand. It would be great for an instruction to run a memory profiling for Rust program on macOS.
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cargo.lock is modified after running cargo package
3 participants