我正在使用Pushlet进行心跳,在请求时CPU达到700%。 我使用jstack转储线程信息。(对于使用jdk1.5运行的服务不使用选项[-l]),所有具有高cpu的线程在读取http流时在doPost中被阻止。 线程的一个堆栈信息如下:
Thread 30777: (state = IN_JAVA) - sun.nio.cs.StreamDecoder$CharsetSD.readBytes() @bci=23, line=401 (Compiled frame ;information may be imprecise) - sun.nio.cs.StreamDecoder$CharsetSD.implRead(char[], int, int) @bci=112, line=453 (Compiled frame) - sun.nio.cs.StreamDecoder.read(char[], int, int) @bci=180, line=183 (Compiled frame) - sun.nio.cs.StreamDecoder.read0() @bci=34, line=132 (Compiled frame) - nl.justobjects.pushlet.servlet.Pushlet.doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) @bci=15, line=117 (Interpreted frame) - javax.servlet.http.HttpServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) @bci=139, line=710 (Interpreted frame) - javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=30, line=803 (Interpreted frame)
请帮助检查为什么在读取流时花费如此多的CPU时间,以何种方式可以检查此问题。
Pushlet.java的代码
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Event event = null; try { // Create Event by parsing XML from input stream. [line 117] event = EventParser.parse(new InputStreamReader(request.getInputStream())); // Always must have an event type if (event.getEventType() == null) { Log.warn("Pushlet.doPost(): bad request, no event specified"); response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No eventType specified"); return; } } catch (Throwable t) { // Error creating event Log.warn("Pushlet: Error creating event in doPost(): ", t); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return; } // Handle parsed request doRequest(event, request, response); }