The SockServer performance is extremely poor when a lot of messages (>100/secs) are sent to the logserver. The problem could be solved by simply making a buffered read from the socket input stream. public SocketNode(Socket socket,Hierarchy hierarchy) { this.socket = socket; this.hierarchy = hierarchy; try { ois = new ObjectInputStream(new BufferedInputStream(socket.getInputStream ())); } catch(Exception e) { cat.error("Could not open ObjectInputStream to "+socket, e); } }
Kok, Thanks for the patch. Have you tried measuring the performance increase? I would like to remind you that TCP sockets are intrinsically buffered. Have you observed a performance increase? Thanks, Ceki
With BufferedInputStream, the performane improved drastically. If you truss -p on the logserver, the read is one character at a time without it. With buffered, it's reading a string at a time (saving the context switching between read). Test 1: Send 100 messages/sec. Before: 7% CPU After : 0.17% CPU Test 2: Send messages in a loop without sleep. Before: 90% after 400 messsages in 40 secs. After : 60% received 25,000 messages in 20 secs.
I have to concur with Kok. I made his suggested improvement in my version of Chainsaw (which also uses ServerSocket and ObjectInputStream), and the throughput of messages went up dramatically. I don't have exact numbers but there was definitely an increase.
OK. I incorporated the change you suggested altough my tests on Windows could not show a difference.