https://bz.apache.org/bugzilla/show_bug.cgi?id=68558

            Bug ID: 68558
           Summary: Redundant calls to ByteChunk.toString()
           Product: Tomcat 9
           Version: 9.0.81
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: jeng...@amazon.com
  Target Milestone: -----

Our high-volume, latency-sensitive application spends approximately 0.16% of
cpu executing org.apache.tomcat.util.buf.ByteChunk.toString. We see only two
direct callers: org.apache.tomcat.util.buf.MessageBytes.toString() and
org.apache.tomcat.util.http.Parameters.processParameters().  Aggregate cost is
split evenly between the two.

Call data shows many different routes trigger both these paths. Examination of
the specific strings being looked up shows:
1. 40% Redundant parsing of key fields on
org.apache.catalina.connector.Request: method, queryString, requestURI,
headerNames, content type.
2. 10% Redundant lookup/iteration of header names
3. 50% Redundant parsing of request parameters, triggered from multiple paths
within the JSP (see stack traces below).

Key portions of the stack traces are included below.

This code can be substantially optimized by locally caching the translated
fields.  Local tests of modifications to the simplest case
(Request.getMethod()) confirm improvement.



org.apache.tomcat.util.buf.StringCache.toString
org.apache.tomcat.util.buf.ByteChunk.toString
org.apache.tomcat.util.buf.MessageBytes.toString
org.apache.catalina.connector.Request.getMethod
org.apache.catalina.connector.RequestFacade.getMethod
javax.servlet.http.HttpServletRequestWrapper.getMethod
javax.servlet.http.HttpServletRequestWrapper.getMethod
org.apache.jsp.WEB_002dINF.<proprietary>.common_jsp._jspService

org.apache.tomcat.util.buf.StringCache.toString
org.apache.tomcat.util.buf.ByteChunk.toString
org.apache.tomcat.util.http.Parameters.processParameters
org.apache.tomcat.util.http.Parameters.processParameters
org.apache.tomcat.util.http.Parameters.handleQueryParameters
org.apache.catalina.core.ApplicationHttpRequest.mergeParameters
org.apache.catalina.core.ApplicationHttpRequest.parseParameters
org.apache.catalina.core.ApplicationHttpRequest.getParameter
javax.servlet.ServletRequestWrapper.getParameter
javax.servlet.ServletRequestWrapper.getParameter
javax.servlet.jsp.el.ImplicitObjectELResolver$ScopeManager$7.getAttribute
javax.servlet.jsp.el.ImplicitObjectELResolver$ScopeManager$7.getAttribute
javax.servlet.jsp.el.ImplicitObjectELResolver$ScopeMap.get
javax.el.MapELResolver.getValue
org.apache.jasper.el.JasperELResolver.getValue
org.apache.el.parser.AstValue.getValue
org.apache.el.ValueExpressionImpl.getValue
org.apache.jasper.el.JspValueExpression.getValue
org.apache.jsp.WEB_002dINF.<proprietary>_jsp._jspx_meth_c_005fset_005f1

Ref: <c:set var = "featureName" value= "${ param.featureName }"/> 


org.apache.tomcat.util.buf.StringCache.toString
org.apache.tomcat.util.buf.ByteChunk.toString
org.apache.tomcat.util.http.Parameters.processParameters
org.apache.tomcat.util.http.Parameters.processParameters
org.apache.tomcat.util.http.Parameters.handleQueryParameters
org.apache.catalina.connector.Request.parseParameters
org.apache.catalina.connector.Request.getParameterNames
org.apache.catalina.connector.Request.getParameterMap
org.apache.catalina.connector.RequestFacade.getParameterMap
<proprietary>Filter.doFilter()

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to