Search code examples
c++multithreadingresolve

Why getnameinfo with multi-thread so slow?


I want to resolve host name by calling getnameinfo() in Linux. To speed up the process, I use a thread pool to resolve host name.
But problem is, the speed is fast at first, then it decrease gradually. After a while, the speed is close to it in one thread. sometimes this function will takes 3 secs and all the threads look like running by order.
I was confused about this. Is there any lock mechanism in the function getnameinfo()?


Solution

  • "threads running by order" strongly suggests it's your locking or request dispatching which causes this. If you think it's a lock, breaking into the debugger should easily allow you to catch the call stack at the time of the lock.