EchoTool icon indicating copy to clipboard operation
EchoTool copied to clipboard

CPU Spike to 100%

Open karan-kang opened this issue 10 years ago • 3 comments

I just tried running your tool with 1KB of data with unlimited number of messages, and it seems the CPU is spiking at 100% while the client server is communicating.

Client: echotool 127.0.0.1 /p tcp /r 5757 /n 0 /d ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef

Server: echotool /p tcp /s 5757

karan-kang avatar Jan 12 '15 18:01 karan-kang

This appears to be an issue with busy waiting in the TcpEchoServer.ServerThread. A quick and dirty fix for me was to add a sleep into the loop (note that this will affect the timeout logic):

while (tcpClient.Client.Connected && serverRunning && !timeOut)
{
    TimeSpan timeoutSpan = DateTime.Now - tcpState.TimeoutWatch;
    if (timeoutSpan.Seconds >= ConnectionTimeout)
        timeOut = true;

    Thread.Sleep(100);
}

CurlingGeek avatar Jan 12 '15 19:01 CurlingGeek

CurlingGeek is right. The problem is that the Thread get the whole cycle busy.

I'll fix it.

PavelBansky avatar Jan 13 '15 15:01 PavelBansky

echotool server.to-test.com /p udp /r 4578 /d Hello

I revceived the message bellow.

This is usually a temporary error during hostname resolution and means that the local server has not received a response from an authorized server.

Este geralmente é um erro temporário durante a resolução do nome do host e significa que o servidor local não recebeu uma resposta de um servidor autorizado

Statistics: Received=0, Corupted=0, Lost=0

belvederecristovao avatar Aug 03 '21 00:08 belvederecristovao