Skip to content

[PPC] Make assembler.cpp compile over 30 times faster #7120

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

bdash
Copy link
Contributor

@bdash bdash commented Jul 18, 2025

Clang was taking around 30 seconds to compile assembler.cpp on my machine, with most of its time spent in code generation for the global initializer for lookup.

Changing the map key from std::string to std::string_view drops compile time to under a second. This is because the compiler no longer has to code gen the allocation, initialization, and moves of 2,100 std::strings. std::string_view is effectively free to initialize in comparison.

While I was here I made the map static const. It's not required for the build time improvement, but it is more correct and helped me check that no-one is mutating the map.

Clang was taking around 30 seconds to compile assembler.cpp on my
machine, with most of its time spent in code generation for the global
initializer for `lookup`.

Changing the map key from `std::string` to `std::string_view` drops
compile time to under a second. This is because the compiler no longer
has to code gen the allocation, initialization, and moves of 2,100
`std::string`s. `std::string_view` is effectively free to initialize in
comparison.

While I was here I made the map `static const`. It's not required for
the build time improvement, but it is more correct and helped me check
that no-one is mutating the map.
Copy link
Member

@plafosse plafosse left a comment

Choose a reason for hiding this comment

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

Approved to push after we've released 5.1 stable

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.

2 participants