-
Notifications
You must be signed in to change notification settings - Fork 621
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
Q: Performance warning #307
Comments
Hey, just my opinion but your second approach would be better suited imo. I'm doing something similar in Go with the bindings I create one network thread whose only job is to send and receive data and keep track of connections, and the game loop thread, and I communicate between the two of them through channels @angelskieglazki. I think it ends up being more performant that way |
We fix some errors in go-wrapper for GNS.. go-wrapper work fine. https://github.com/angelskieglazki/gns My research in C++ continues. :) |
I've forked your version and using my own gns bindings now, as I have more control over every aspect |
If you are accessing the same connection from many different threads at a time, you will probably get a lot of contention. In general, sending and receiving messages does not take the global lock, but it does take the lock of whatever connection or poll group you are accessing. You might also try sending many messages to the API at once, using It looks to me that you are not necessarily getting contention, it's just that the service thread is taking a while to service all of the connections for some reason. If you have any tools for profiling, I would be interested to know what the cause is. If you only have a few dozen connections, it should be able to service them efficiently. You might double check that you are not compiling the library in debug, or doing something that might cause SNP_PARANOIA to be active. This adds quite a bit of CPU time. |
can I take a look at your wrapper? |
Hello!
Are these messages normal? It seems to me that I am doing something wrong.
I’ll describe a little how my game server works, there are two threads from which the GNS api is called.
so this thread is running and then we will get a message about creating a game room:
Сlients send reliable messages with positions about 50 times per second. Starting from 30+ players, lags begin and warnings begin to spam.
I started thinking and this is what I came up with: if 30 players are connected and they send 50 messages per second, then 1500 times per second I call GNS-api. Since I am not calling it from a network thread, GNS-mutexes will be locked there, which is what I see (0.000000 Waited 2.4ms for SteamNetworkingSockets lock ... and so on).
Perhaps I should send and receive messages in only one network thread, then the thread-contention will be minimal and the wait on the GNS mutexes will also be minimal. And the room threads will communicate with the network thread through queues, which I will somehow exchange under my mutex.
In general, I want to consult with you :)
regards, max
The text was updated successfully, but these errors were encountered: