-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
build: speedup #1180
Comments
I’ll look into the build performance issue later. |
Due to the inefficiency of std::regex, it often takes over 90% of compile time (e.g., 10 seconds on my laptop). Many discussions online highlight that std::regex is slow both to compile and at runtime. Aside from switching to a more efficient regex library, there are few good solutions. |
Why does removing -g speed it up significantly? |
Also, this only takes 3s with all the regex:
It appears just adding an empty regex in the real dbc.cc causes a 2x slowdown, and subsequent patterns take almost no extra compile time. |
std::regex generates a large amount of complex template code, leading to template bloat, which causes the compiler to take more time to process. This is especially true when the -g flag is enabled to generate debug information, as the compiler needs to produce detailed debug data for all the expanded templates. |
RE2 looks like a good alternative to std::regex, it's has minimal headers and relatively small lib compare to other reg lib. |
Can we precompile the regex stuff and check it in? I think another library is not worth it (unless super small), but it might be worth having to check in a new pre-compiled header when it changes. |
Clang compiles template-heavy code like std::regex more efficiently than g++, potentially improving DBC compile times by up to 30%. However, the core issue of std::regex's complex template instantiations remains. Precompiling dbc.cc into platform-specific libraries (e.g., /precompiled/Darwin, /precompiled/arm64) may help but adds complexity to the build process and feels somewhat unusual. |
@deanlee interesting in checking out why some objects take so long to build?
The text was updated successfully, but these errors were encountered: