Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

High CPU usage when using ClientRPC #9

Open
OneFirefly opened this issue Nov 29, 2020 · 1 comment
Open

High CPU usage when using ClientRPC #9

OneFirefly opened this issue Nov 29, 2020 · 1 comment

Comments

@OneFirefly
Copy link

OneFirefly commented Nov 29, 2020

mutex_eating_cpu

I just profiled my application in server only mode with 4 remote clients
ClientRPCs seem to be blocking due to mutexes (see image) - The profiled Ping method is a ClientRPC and there are others like this that block > 3ms.
Those ClientRPCs usually have not more than 1 primitive parameter (e.g. int)

@OneFirefly
Copy link
Author

Fix is:

replace:
https://github.com/MirrorNG/WebsocketNG/blob/616049c7a860a7bb1a753af9ab38c0bbe79b5b99/Assets/Mirror/Websocket/Common/SendLoop.cs#L20-L22
with:

if (queue.Count > 0) {
	MemoryStream msg = queue.Take(cancellationToken);
	stream.Write(msg.GetBuffer(), 0, (int)msg.Length);
}

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

No branches or pull requests

1 participant