Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread creation overhead due to cgo calls #88

Open
NeetishPathak opened this issue Apr 16, 2018 · 4 comments
Open

Thread creation overhead due to cgo calls #88

NeetishPathak opened this issue Apr 16, 2018 · 4 comments

Comments

@NeetishPathak
Copy link

The connections in Spacemonkey openssl wrapper makes use of cgo calls and this is an issue because it leads to massive number of threads for simultaneous ssl connections. cgo marks all C code as syscall causing scheduler to allocate a new thread if needed. Can this be addressed ?

@zeebo
Copy link
Member

zeebo commented Apr 16, 2018

The library tries to do a good job about only doing short cgo calls: they should all return quickly.

Do you have a short example demonstrating the problem?

@pvoicu
Copy link

pvoicu commented May 3, 2018

Indeed the cgo calls are short because they are not waiting for IO, however internally functions like SSL_do_handshake, SSL_read, SSL_write are making a lot of mutex lock()/unlock() calls. I put a trace in https://github.com/spacemonkeygo/openssl/blob/master/init_posix.go, I see hundreds of calls. This is source of contention and for higher load (2000 handshakes per second on my dev machine) I see a spike in the number of threads created by the runtime and a performance degradation.
Do you have a suggestion for the contention caused by the openssl mutexes? Should we compile openssl with no threads support since all the calls from spacemonkeygo into openssl are protected by mutexes anyway?

@slucx
Copy link

slucx commented Jun 21, 2019

I have the same problem.

@slucx
Copy link

slucx commented Jun 21, 2019

I think it is limit of go GPM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants