ClickHouse/base/common/phdr_cache.h

20 lines
942 B
C++
Raw Normal View History

#pragma once
2019-07-25 19:56:51 +00:00
/// This code was based on the code by Fedor Korotkiy (prime@yandex-team.ru) for YT product in Yandex.
2019-07-25 22:35:47 +00:00
/** Collects all dl_phdr_info items and caches them in a static array.
* Also rewrites dl_iterate_phdr with a lock-free version which consults the above cache
* thus eliminating scalability bottleneck in C++ exception unwinding.
* As a drawback, this only works if no dynamic object unloading happens after this point.
* This function is thread-safe. You should call it to update cache after loading new shared libraries.
* Otherwise exception handling from dlopened libraries won't work (will call std::terminate immediately).
*
* NOTE: It is disabled with Thread Sanitizer because TSan can only use original "dl_iterate_phdr" function.
*/
2019-07-25 19:54:16 +00:00
void updatePHDRCache();
2019-07-25 22:35:47 +00:00
/** Check if "dl_iterate_phdr" will be lock-free
* to determine if some features like Query Profiler can be used.
*/
bool hasPHDRCache();