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

feat: Deduplicate crates when extending crate graphs #14659

Merged
merged 1 commit into from
Apr 26, 2023

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Apr 26, 2023

This is quadratic in runtime per deduplication attempt, but I don't think that'll be a problem for the workload here. Don't be scared of the diff, the actual diff is +42 -22, the rest is tests and test data.
Fixes #14476

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 26, 2023
Comment on lines 211 to 238

#[test]
fn crate_graph_dedup_identical() {
let (mut crate_graph, proc_macros) =
load_cargo_with_sysroot(&mut Default::default(), "regex-metadata.json");
crate_graph.sort_deps();

let (d_crate_graph, mut d_proc_macros) = (crate_graph.clone(), proc_macros.clone());

crate_graph.extend(d_crate_graph.clone(), &mut d_proc_macros);
assert!(crate_graph.iter().eq(d_crate_graph.iter()));
assert_eq!(proc_macros, d_proc_macros);
check_crate_graph(
crate_graph,
expect_file!["../test_data/output/crate_graph_dedup_identical.txt"],
);
}

#[test]
fn crate_graph_dedup() {
let path_map = &mut Default::default();
let (mut crate_graph, _proc_macros) =
load_cargo_with_sysroot(path_map, "ripgrep-metadata.json");
assert_eq!(crate_graph.iter().count(), 81);
crate_graph.sort_deps();
let (regex_crate_graph, mut regex_proc_macros) =
load_cargo_with_sysroot(path_map, "regex-metadata.json");
assert_eq!(regex_crate_graph.iter().count(), 60);

crate_graph.extend(regex_crate_graph, &mut regex_proc_macros);
assert_eq!(crate_graph.iter().count(), 118);
check_crate_graph(crate_graph, expect_file!["../test_data/output/crate_graph_dedup.txt"])
}
Copy link
Member Author

Choose a reason for hiding this comment

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

So no one has to sift through the massive diff due to test files, this is where the tests are :)

@Veykril
Copy link
Member Author

Veykril commented Apr 26, 2023

@bors r+

@bors
Copy link
Contributor

bors commented Apr 26, 2023

📌 Commit de8aac1 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Apr 26, 2023

⌛ Testing commit de8aac1 with merge 2e2d6f4...

bors added a commit that referenced this pull request Apr 26, 2023
Deduplicate crates when extending crate graphs

This is quadratic in runtime per deduplication attempt, but I don't think that'll be a problem for the workload here. Don't be scared of the diff, the actual diff is +42 -22, the rest is tests and test data.
Fixes #14476
@Veykril
Copy link
Member Author

Veykril commented Apr 26, 2023

@bors r-

@Veykril
Copy link
Member Author

Veykril commented Apr 26, 2023

@bors r+

@bors
Copy link
Contributor

bors commented Apr 26, 2023

📌 Commit 968850d has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Apr 26, 2023

⌛ Testing commit 968850d with merge 797c2f1...

@bors
Copy link
Contributor

bors commented Apr 26, 2023

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 797c2f1 to master...

@bors bors merged commit 797c2f1 into rust-lang:master Apr 26, 2023
@lnicola lnicola changed the title Deduplicate crates when extending crate graphs feat: Deduplicate crates when extending crate graphs Apr 26, 2023
@Veykril Veykril deleted the dedup-crates branch August 2, 2023 08:14
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.

Deduplicate crates in crate graph
3 participants