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

Slow frame functions #193

Open
HazyMrf opened this issue Oct 24, 2024 · 4 comments
Open

Slow frame functions #193

HazyMrf opened this issue Oct 24, 2024 · 4 comments
Labels

Comments

@HazyMrf
Copy link

HazyMrf commented Oct 24, 2024

Hello! I use boost stacktrace library and frame functions like name() are taking too much time (like +-10seconds) probably because of the large binary (about 35MB). Is there any way I can speed up these functions?

SetUp
Compiler: clang-18
Flags: -DBOOST_STACKTRACE_USE_BACKTRACE -DBOOST_STACKTRACE_LINK

@apolukhin
Copy link
Member

What flag do you use for compiling your application? Are you using SSD? What operating system do you use?

@HazyMrf
Copy link
Author

HazyMrf commented Oct 30, 2024

Thank you @apolukhin for such a quick response!
Flags: -fno-pie -fvisibility-inlines-hidden -O3 -funroll-loops -fno-omit-frame-pointer -flto=thin
-DNDEBUG -DBOOST_STACKTRACE_USE_BACKTRACE -DBOOST_STACKTRACE_LINK
SSD is not used
OS is Ubuntu20

@apolukhin
Copy link
Member

@HazyMrf 35mb does seem to be big enough to drastically slow down the name() function.

My guesses are:
0. Try preload all the internal staff by calling to_string(boost::stacktrace::stacktrace()). Does it help the subsequent calls?

  1. You are throwing exceptions or getting other stacktraces concurrently. Ubuntu20 has an old libc that locks+unlocks mutex on each frame unwinding. As a result multiple concurrent exceptions|backtraces could degrade performance to multiple seconds per one function call. The most simple solution - is to migrate to a new distro.
  2. Try defining BOOST_STACKTRACE_BACKTRACE_FORCE_STATIC while compiling the boost.stacktrace library. Does it help?

@HazyMrf
Copy link
Author

HazyMrf commented Jan 9, 2025

Nope, any of the things you suggested didn't help :( Well I'll continue to use address() because it is extremely cheap. I've always thought that addr2line is slow and when using backtrace / libbacktrace I'll get super-performance, but I was mistaken...

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

No branches or pull requests

2 participants