Note that there are some explanatory texts on larger screens.

plurals
  1. POReasons for high CPU usage in SocketInputStream.socketRead0()
    primarykey
    data
    text
    <p>While profiling homegrown web-application I came across following very strange (at least for me) observation.</p> <p>Almost all time is spent in <code>socketRead0()</code> method of a <code>SocketInputStream</code> class. It's not surprising because my application do a networking with a remote service on each request. What is strange that not only <em>wall clock time</em> usage is high for this method, <em>CPU clock time</em> also very high. I can't understand why CPU time is high, because if my application wait for remote service to reply (which is not so fast in fact), there is nothing to do left for application itself. So CPU time should be apparently low.</p> <p>Some more observation:</p> <ul> <li>VisualVM in sampling mode shows that method <code>SocketInputStream.socketRead0()</code> is eating up to 95% of time (both wall clock time <strong>and</strong> CPU time);</li> <li><code>mpstat</code> (we use Linux as a OS) shows around ~90% user time and ~1-3% system time (the rest is idle time);</li> <li>application deployed on the dedicated server;</li> <li>remote service is HTTP web-application also. Average response time is about 100ms. Average response size is about 2Kb.</li> <li>my application use spring <code>RestTemplate</code> to interact with remote service, not the <code>SocketInputStream</code> directly.</li> </ul> <p>For now I have only one idea — maybe this is overhead of calling native methods in JVM (<code>SocketInputStream.socketRead0()</code> is native)?</p> <p>What do you think? Is there any other reasons to this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload