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

Generate less bloaty code for errors::windows enums #861

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Swatinem
Copy link
Collaborator

@Swatinem Swatinem commented Jul 30, 2023

Not really intended to be merged, feel free to ignore. This solves #847, but at the cost of tons of generated code.

This is just an experiment to see if custom Debug and from_u64/u32 code based on PHF leads to better codegen.
On my windows system, a full lto compile using cargo bloat shrinks the resulting binary of minidump-stackwalk by 100k, (from 10M to 9.9M), with a tiny regression to the debug data size.

The full story of what I did is documented here: https://swatinem.de/blog/optimizing-enums/

Ideally the Rust compiler would do this optimization internally and not generate such code in the first place.

This is just an experiment to see if custom `Debug` and `from_u64/u32` code based on PHF leads to better codegen.
@gabrielesvelto
Copy link
Collaborator

This is a nice improvement! I don't mind merging a bunch of generated code but would you prefer waiting to see if the compiler issue gets some traction first?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants