Skip to content

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

Merged
bdash merged 1 commit intodevfrom
ppc-assembler-compile-time
Jul 29, 2025
Merged

[PPC] Make assembler.cpp compile over 30 times faster#7120
bdash merged 1 commit intodevfrom
ppc-assembler-compile-time

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.

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

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.
@bdash bdash force-pushed the ppc-assembler-compile-time branch from 17c9420 to 435284e Compare July 29, 2025 02:28
@bdash bdash merged commit 435284e into dev Jul 29, 2025
5 checks passed
@bdash bdash deleted the ppc-assembler-compile-time branch July 29, 2025 02:34
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

Comments