-
Notifications
You must be signed in to change notification settings - Fork 39
Description
In my performance tests I have observed that after a pthread gets created, it uses a small, but noticeable amount of overhead, even when it is not doing any work.
Profiling shows __pthread_enable_asynccancel and __pthread_disable_asynccancel as the functions being called. On the techempower JSON test, performance increased by 3-4% when this overhead was removed by using a custom version of reactor_net_bind that doesn't use reactor_pool.
I assume the thread pool is used by reactor_resolver_request because getaddrinfo is a blocking call. My suggestion is to add something like reactor_resolver_request_ip that takes a struct in_addr * builds an addrinfo struct without calling getaddrinfo.
This could then be used by reactor_net_bind which in most cases is being bound to an IP address. We can call inet_pton to see if the address is a valid IP and get the in_addr struct. If it isn't, we simply fall back to using the existing reactor_resolver_request function.
Let me know if I should go ahead and create a PR to demonstrate this approach.