Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-45734

UrlRewriteFilter might cause sudden CPU spikes

    Details

      Description

      Description

      UrlRewriteFilter doesn't ignore ComboServlet and processes its URLs unnecessarily. When those URLs which are addressing ComboServlet are long (~1Kb), parsing them by UrlRewriteFilter becomes expensive and causes sudden CPU spikes.

      Steps to reproduce

      1) Set the following JVM options in setenv.sh

      export HPROF_START=$(date +%Y%m%d.%H%M%S)
      export JAVA_OPTS="$JAVA_OPTS -Xrunhprof:cpu=samples,doe=n,thread=n,format=a,file=${CATALINA_HOME}/logs/java.${HPROF_START}.hprof"
      

      2) Start the portal

      3) Reset CPU samples by issuing

      % kill -QUIT <pid>
      

      4) Generate load by accessing the following URL concurently

      /combo/?browserId=other&minifierType=&languageId=nl_BE&b=6130&t=1396260298000&p=/html/js&m=/aui/aui-char-counter/aui-char-counter-min.js&m=/aui/aui-datatype/aui-datatype-min.js&m=/aui/datatype-date-parse/datatype-date-parse-min.js&m=/aui/datatype-date-format/lang/datatype-date-format_en-US.js&m=/aui/datatype-date-format/datatype-date-format-min.js&m=/aui/widget-locale/widget-locale-min.js&m=/aui/aui-calendar/aui-calendar-min.js&m=/aui/aui-datepicker/aui-datepicker-base-min.js&m=/aui/aui-state-interaction/aui-state-interaction-min.js&m=/aui/aui-button-item/aui-button-item-min.js&m=/aui/aui-datepicker/aui-datepicker-select-min.js&m=/aui/dd-ddm-base/dd-ddm-base-min.js&m=/aui/dd-drag/dd-drag-min.js&m=/aui/dd-ddm/dd-ddm-min.js&m=/aui/dd-ddm-drop/dd-ddm-drop-min.js&m=/aui/dd-drop/dd-drop-min.js&m=/aui/dd-drop-plugin/dd-drop-plugin-min.js&m=/aui/dd-delegate/dd-delegate-min.js&m=/aui/datasource-local/datasource-local-min.js&m=/aui/datasource-io/datasource-io-min.js&m=/aui/datasource-get/datasource-get-min.js&m=/aui/datasource-function/datasource-function-min.js&m=/aui/cache-base/cache-base-min.js&m=/aui/datasource-cache/datasource-cache-min.js&m=/aui/dataschema-base/dataschema-base-min.js&m=/aui/dataschema-json/dataschema-json-min.js&m=/aui/datasource-jsonschema/datasource-jsonschema-min.js&m=/aui/dataschema-xml/dataschema-xml-min.js&m=/aui/datasource-xmlschema/datasource-xmlschema-min.js&m=/aui/dataschema-array/dataschema-array-min.js&m=/aui/datasource-arrayschema/datasource-arrayschema-min.js&m=/aui/dataschema-text/dataschema-text-min.js&m=/aui/datasource-textschema/datasource-textschema-min.js&m=/aui/datasource-polling/datasource-polling-min.js&m=/aui/aui-form/aui-form-field-min.js&m=/aui/aui-form/aui-form-textfield-min.js
      

      5) Gather CPU samples again by issuing

      % kill -QUIT <pid>
      

      6) Check the last CPU SAMPLES section of the HPROF file, you should see something like this

      CPU SAMPLES BEGIN (total = 266475) Fri Apr  4 10:55:43 2014
       rank   self  accum   count trace method
          1 40.90% 40.90%  108975 303724 java.util.regex.Pattern$GroupTail.match
          2 30.92% 71.81%   82383 303727 java.util.regex.Pattern$Curly.match0
          3  8.13% 79.94%   21664 303741 java.util.regex.Pattern$Curly.match0
          4  3.21% 83.15%    8559 303735 java.util.regex.Pattern$Curly.match0
          5  1.84% 85.00%    4911 302874 java.util.zip.Deflater.deflateBytes
          6  1.53% 86.53%    4081 302451 java.net.PlainSocketImpl.socketAccept
          7  1.23% 87.76%    3280 304394 com.ctc.wstx.io.ReaderBootstrapper.bootstrapInput
          8  0.84% 88.59%    2230 304399 org.tuckey.web.filters.urlrewrite.utils.Log.isUsingLog4j
          9  0.74% 89.34%    1985 304393 com.liferay.portal.service.ServiceContextFactory.getInstance
         10  0.52% 89.86%    1375 304655 com.liferay.portal.sharepoint.SharepointFilter.isSharepointRequest
         ...
      CPU SAMPLES END
      

      UrlRewriteFilter gets applied to ComboServlet and causes high CPU usage, java.util.regex.Pattern$GroupTail.match is in the top of the profiler output
      UrlRewriteFilter ignores ComboServlet, doesn't cause high CPU usage and java.util.regex.Pattern$GroupTail.match disappears from the top of the profiler output

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  4 years, 41 weeks ago

                  Packages

                  Version Package
                  6.1.X EE
                  6.2.3 CE GA4
                  6.2.X EE
                  7.0.0 M3