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

Add a twiggy garbage subcommand to find unreachable items #48

Closed
fitzgen opened this issue May 4, 2018 · 5 comments · Fixed by #50
Closed

Add a twiggy garbage subcommand to find unreachable items #48

fitzgen opened this issue May 4, 2018 · 5 comments · Fixed by #50
Labels
assigned enhancement New feature or request help wanted Extra attention is needed mentored

Comments

@fitzgen
Copy link
Member

fitzgen commented May 4, 2018

This would print code and data that is not transitively referenced by any exports / public functions. Since linkers and compilers tend to remove dead code, this is more likely to find bugs in our IR graph, but that is also a useful thing ;)

@fitzgen fitzgen added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers mentored and removed good first issue Good for newcomers labels May 4, 2018
@data-pup
Copy link
Member

data-pup commented May 7, 2018

This looks like it would be fun! I would love to try and tackle this one. I can start looking into it tomorrow I believe. Let me know if you have any advice :)

@fitzgen
Copy link
Member Author

fitzgen commented May 7, 2018

@data-pup great! I would suggest using petgraph::visit::Dfs traversal starting from the meta-root to collect the set of all items that are not garbage (ie transitively reachable from some exported or public item). Then, I would iterate over all items, filtering them down to just the items that aren't in the reachable set (ie are garbage), and then sort those garbage items by size. Does that all make sense?

@fitzgen
Copy link
Member Author

fitzgen commented May 7, 2018

This would mostly be implemented in analyze/analyze.rs. Although there is a bit of plumbing to add in most of the crates.

aa3330d is a good example of what implementing a new sub command is like.

@data-pup
Copy link
Member

data-pup commented May 7, 2018

Awesome! That makes sense to me 🙂

@data-pup
Copy link
Member

data-pup commented May 9, 2018

I think I'm getting pretty close to having this done! I should be able to open a PR today for review :D

data-pup added a commit to data-pup/twiggy that referenced this issue May 9, 2018
data-pup added a commit to data-pup/twiggy that referenced this issue May 9, 2018
fitzgen added a commit that referenced this issue May 9, 2018
Add a `twiggy garbage` command. Fixes issue #48.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assigned enhancement New feature or request help wanted Extra attention is needed mentored
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants