Closed zhangbo1882 closed 2 years ago
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
For more information, open the CLA check for this pull request.
@DrJosh9000 @liuyuan10 @unicell , could you help review this PR ?
@liuyuan10 , comment resolved. Thanks for your good suggestion.
@liuyuan10 , any update ? Thanks.
Please fix the unit test. looks like ipv6 is broken.
/retest
@liuyuan10 , I have fixed the unit test issue. But I do not know how to trigger the CI.
Thanks for the change!
For the golang goroutine scheduler algorithm (GMP model), if the gorouting calls a blocking system call, the current P will not release the current M (thread). If there is another G want to run, a new M (thread) must be created. Current tcp health check use syscall.Connect to connect to the target. If there are many goroutines which call tcp health check at the same time, golang may create thousands of threads.
Actually, golang runtime has provided the dial package to optimize this issue which will use the netpoll unblocking I/O. In my test env, I run 100000 goroutine, golang create nearly 8000 thread which is up to the max thread(10000) that golang can support by default.
With the fix in this PR, the thread number is only about 120.