consulo/UnityEditorConsuloPlugin

CPU spike when Consulo is closed.

brogan89 opened this issue · 4 comments

Hey was getting massive cpu spikes when in Unity play mode. Consulo wasn't opened, so opening the Consulo project fixed it. I looks like a regression from issue #100

spike-consuloclosed

It look like it is because of this section

using (Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))

Hello. Oh. I known that code - but not expect problem like this.

I have no idea how good rewrite it for now.

Consulo path is not stable (user can change it). Also - consulo settings paths can be changed.

For now - it's trying send to stable port of Consulo REST API.

Thanks. I will think about that problem

I am not too sure about code so I am only guessing when saying this, but would it be better to set up a UDP broadcasting system rather than Socket connection. It doesn't even look like the socket is being used once socket is connected since in using(). UDP you can just send messages to localhost:port and it doesn't matter if there is listener or not which it looks you are kind of doing here

WebRequest request = WebRequest.Create("http://localhost:" + PluginConstants.ourPort + "/api/" + url);
but im guessing this is TPC by default which requires a response.

Otherwise, it might be better to just check if process is running. This will be faster as you don't need to wait for Socket connection. https://stackoverflow.com/questions/262280/how-can-i-know-if-a-process-is-running

I'm not expert in networking however, so take my suggestion with grain of salt :)

About code - it's always request body in WriteCallback.

About process list - i forgot why i don't use it (it was an option - but i refused it)

Thanks

Hello. Again. I am working at migration to Asset Store, and testing new functional via process list.

There a problem. Process can't access to admin processes (for example unity run with user rights, consulo with admin rights).

I add code searching via process list, but socket search exists too (but i will add preprocessor variable for disabling this logic CONSULO_DISABLE_SOCKET_SEARCHING or via menu item)

Thanks