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

Rework DepthFirstSearch API #88711

Merged
merged 1 commit into from
Sep 12, 2021
Merged

Conversation

Mark-Simulacrum
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum commented Sep 7, 2021

This expands the API to be more flexible, allowing for more visitation patterns
on graphs. This will be useful to avoid extra datasets (and allocations) in
cases where the expanded DFS API is sufficient.

This also fixes a bug with the previous DFS constructor, which left the start
node not marked as visited (even though it was immediately returned).

Commit written by @nikomatsakis originally, cherry picked from several commits in work on never type stabilization, but stands alone.

@rust-highfive
Copy link
Collaborator

r? @estebank

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 7, 2021
@Mark-Simulacrum Mark-Simulacrum changed the title Fix bug in DepthFirstSearch where start node may be visited twice Rework DepthFirstSearch API Sep 7, 2021
@Mark-Simulacrum
Copy link
Member Author

Switched the commit in this PR to also include a later patch set reworking the API further and coincidentally fixing the bug previously noted. Should avoid wasting time on reviewing a soon to be unnecessary patch set, while still achieving the same goals as before.

@jackh726
Copy link
Member

jackh726 commented Sep 8, 2021

r? @jackh726

r=me with/without nit

@rust-highfive rust-highfive assigned jackh726 and unassigned estebank Sep 8, 2021
This expands the API to be more flexible, allowing for more visitation patterns
on graphs. This will be useful to avoid extra datasets (and allocations) in
cases where the expanded DFS API is sufficient.

This also fixes a bug with the previous DFS constructor, which left the start
node not marked as visited (even though it was immediately returned).
@Mark-Simulacrum
Copy link
Member Author

@bors r=jackh726

@bors
Copy link
Contributor

bors commented Sep 8, 2021

📌 Commit c9d46eb has been approved by jackh726

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 8, 2021
Manishearth added a commit to Manishearth/rust that referenced this pull request Sep 12, 2021
…h726

Rework DepthFirstSearch API

This expands the API to be more flexible, allowing for more visitation patterns
on graphs. This will be useful to avoid extra datasets (and allocations) in
cases where the expanded DFS API is sufficient.

This also fixes a bug with the previous DFS constructor, which left the start
node not marked as visited (even though it was immediately returned).

Commit written by `@nikomatsakis` originally, cherry picked from several commits in work on never type stabilization, but stands alone.
Manishearth added a commit to Manishearth/rust that referenced this pull request Sep 12, 2021
…h726

Rework DepthFirstSearch API

This expands the API to be more flexible, allowing for more visitation patterns
on graphs. This will be useful to avoid extra datasets (and allocations) in
cases where the expanded DFS API is sufficient.

This also fixes a bug with the previous DFS constructor, which left the start
node not marked as visited (even though it was immediately returned).

Commit written by ``@nikomatsakis`` originally, cherry picked from several commits in work on never type stabilization, but stands alone.
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 12, 2021
…arth

Rollup of 7 pull requests

Successful merges:

 - rust-lang#88336 ( Detect stricter constraints on gats where clauses in impls vs trait)
 - rust-lang#88677 (rustc: Remove local variable IDs from `Export`s)
 - rust-lang#88699 (Remove extra unshallow from cherry-pick checker)
 - rust-lang#88709 (generic_const_exprs: use thir for abstract consts instead of mir)
 - rust-lang#88711 (Rework DepthFirstSearch API)
 - rust-lang#88810 (rustdoc: Cleanup `clean` part 1)
 - rust-lang#88813 (explicitly link to external `ena` docs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b87d0d0 into rust-lang:master Sep 12, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 12, 2021
@Manishearth
Copy link
Member

The rollup caused an instruction count increase on perf, do you think that's due to this PR?

#88881

https://perf.rust-lang.org/compare.html?start=9ef27bf7dc50a8b51435579b4f2e86f7ee3f7a94&end=c7dbe7a830100c70d59994fd940bf75bb6e39b39

@Mark-Simulacrum Mark-Simulacrum deleted the fix-dfs-bug branch September 12, 2021 19:29
@Mark-Simulacrum
Copy link
Member Author

It seems pretty unlikely, though not impossible. The only (that I can find) user of DFS today is the reverse scc computation here. As far as I can tell, that code certainly runs a lot, but I wouldn't expect a fundamental difference -- if anything, the new behavior should be a little faster since we're only returning the start node once (and not maybe twice).

But it's hard to say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants