Closed
Description
It appears that a call to Aws::initAPI() spawns '# cpu cores / 2' threads but so far I've been unable to find any documentation on how or why this happens, or how to configure it.
We spawn multiple process that call Aws::InitAPI and on a high cpu count machine this results in more than 2000 threads spawned by the SDK. As threads/PID's are not an infinite resource, any advice on how to remove/limit this behaviour would be appreciated.
Minimal reproducable example:
#include <thread>
#include <chrono>
#include <aws/core/Aws.h>
int main(int, char**)
{
Aws::SDKOptions options;
Aws::InitAPI(options);
std::this_thread::sleep_for( std::chrono::seconds( 600 ) );
return 0;
}
Compile & run and then do a pstack on its pid, you'll see multiple threads like:
Thread 19 (Thread 0x7f70257e2700 (LWP 301201)):
#0 0x00007f70349fc923 in epoll_wait () from /lib64/libc.so.6
#1 0x00007f7035b73c1b in s_main_loop () from /path/to/aws/1.9.114/lib64/libaws-cpp-sdk-core.so
#2 0x00007f7035c2ed5f in thread_fn () from /path/to/aws/1.9.114/lib64/libaws-cpp-sdk-core.so
#3 0x00007f7034ccee25 in start_thread () from /lib64/libpthread.so.0
#4 0x00007f70349fc34d in clone () from /lib64/libc.so.6