nng icon indicating copy to clipboard operation
nng copied to clipboard

Define NNG_EXPIRE_THREADS not set in CMakeLists.txt

Open JochenBaier opened this issue 2 years ago • 2 comments

The define NNG_EXPIRE_THREADS not set in CMakeLists.txt. Define is used in nni_aio_sys_init().

Fix in CMakeLists.txt:

if (NNG_EXPIRE_THREADS) add_definitions(-DNNG_EXPIRE_THREADS=${NNG_EXPIRE_THREADS}) endif () mark_as_advanced(NNG_EXPIRE_THREADS)

JochenBaier avatar Sep 19 '22 20:09 JochenBaier

so what does this patch help?

LowLevelMahn avatar Sep 23 '22 06:09 LowLevelMahn

so what does this patch help?

Related to "nng creates a massive amount of threads on high core count machines" https://github.com/nanomsg/nng/issues/1572:

JochenBaier avatar Sep 23 '22 10:09 JochenBaier

Yes, it would be good to have this as a tunable in the CMakeLists.

gdamore avatar Oct 17 '22 05:10 gdamore

@gdamore at the end only the NNG_MAX_EXPIRE_THREADS was added. Code still uses NNG_EXPIRE_THREADS that effectively overrides NNG_MAX_EXPIRE_THREADS.

Should we apply something similar to how taskq limits are set?

Having a max value (NNG_MAX_EXPIRE_THREADS) that only caps the number of tasks, default to 8 or 256 (CMake default is 8 today but code imposes 256 limit).

And having a NNG_NUM_EXPIRE_THREADS that overrides the value, but still obeys the limit?

I have an MR for that if you want.

phsilva avatar Aug 23 '23 18:08 phsilva

Go ahead and submit the PR. Cannot promise it will merge, but it might, and cannot hurt to look.

The taskqs needs to have a minimum of 2, or else deadlocks may occur.

gdamore avatar Aug 23 '23 18:08 gdamore