Fix extremely slow stack traces in debug build#44569
Fix extremely slow stack traces in debug build#44569alexey-milovidov merged 3 commits intomasterfrom
Conversation
| set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS}") | ||
| set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 ${DEBUG_INFO_FLAGS} ${CMAKE_CXX_FLAGS_ADD}") | ||
| set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 ${DEBUG_INFO_FLAGS} -fno-inline ${CMAKE_CXX_FLAGS_ADD}") | ||
| set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 ${DEBUG_INFO_FLAGS} ${CMAKE_CXX_FLAGS_ADD}") |
There was a problem hiding this comment.
Please note that -fno-inline is the default for -O0:
-fno-inline
Do not expand any functions inline apart from those marked with the "always_inline" attribute. This is the default when not optimizing.
src/Common/CMakeLists.txt
Outdated
| endif () | ||
|
|
||
| # Otherwise stack traces symbolization is painfully slow in debug build. | ||
| set_source_files_properties("Dwarf.cpp" PROPERTIES COMPILE_FLAGS "-O3") |
There was a problem hiding this comment.
I guess -O2 is enough? (-O3 make it harder to debug)
There was a problem hiding this comment.
Yes, most likely it's enough.
There was a problem hiding this comment.
And there is already similar lines -
Lines 342 to 347 in d8924f0
|
|
||
| # We should enable optimizations (otherwise it will be too slow in debug) | ||
| # and disable sanitizers (otherwise infinite loop may happen) | ||
| target_compile_options(unwind PRIVATE -O3 -fno-exceptions -funwind-tables -fno-sanitize=all $<$<COMPILE_LANGUAGE:CXX>:-nostdinc++ -fno-rtti>) |
There was a problem hiding this comment.
Maybe you can also switch to -O2 instead here and here
Lines 342 to 347 in d8924f0
This will allow to debug unwind issues in debug builds w/o rebuilding.
|
@alexey-milovidov BTW maybe it worth to add a test to ensure that this will not became worse? (since it can be pretty tricky to dig into this again) |
|
@azat I was thinking about it, but it's difficult to imagine this test being not fragile. |
Changelog category (leave one):
The issue sometimes appear in tests:
It's unclear why it took more than 10 minutes (most likely - many parallel queries),
but even on my machine, it was more than 1 second.
Now 0.1 seconds.
Note: maybe we also need to mlock the debug info in the binary or put the binary into tmpfs.