Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-2998

Serious OGNL Performance Issues

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 2.0.11
    • 2.3.1
    • Expression Language
    • None
    • Windows XP 5.1 (2Gb, dual-core 1.8GHz), Java 1.5.0_08, Tomcat 5.5

    • Important

    Description

      I am currently running Struts 2.0.11 (planning to upgrade soon) with OGNL 2.6.11 and am having significant trouble with the appalling performance of OGNL.

      The following XML using Struts 2 Tags and OGNL takes (using the s2 profiling) 2328ms to render

      <%@ page contentType="text/xml" %><%--
      -%><%@ taglib prefix="s" uri="/struts-tags" %><%-
      -%><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><%-
      --%><?xml version="1.0" ?>
      <response>
      <entities>
      <s:iterator value="entities" id="entity">
      <entity <%--
      -%>id="<s:property value="id"/>" <%-
      -%>name="<s:property value="name"/>" <%-
      -%>externalId="<s:property value="externalId"/>" <%-
      -%>color="<s:property value="renderColor"/>" <%-
      -%>image="<s:property value="image.path"/>" <%-
      -%>includeInKey="<s:property value="includeInKey"/>" <%-
      -%>orderRank="<s:property value="orderRank"/>" <%-
      --%> />
      </s:iterator>
      </entities>
      </response>

      The exact same functionality, using JSTL tags and EL, takes 15ms

      <%@ page contentType="text/xml" %><%--
      -%><%@ taglib prefix="s" uri="/struts-tags" %><%-
      -%><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><%-
      --%><?xml version="1.0" ?>
      <response>
      <entities>
      <c:forEach items="${entities}" var="entity">
      <entity <%--
      -%>id="<c:out value="${entity.id}"/>" <%-
      -%>name="<c:out value="${entity.name}"/>" <%-
      -%>externalId="<c:out value="${entity.externalId}"/>" <%-
      -%>color="<c:out value="${entity.renderColor}"/>" <%-
      -%>image="<c:out value="${entity.image.path}"/>" <%-
      -%>includeInKey="<c:out value="${entity.includeInKey}"/>" <%-
      -%>orderRank="<c:out value="${entity.orderRank}"/>" <%-
      --%> />
      </c:forEach>
      </entities>
      </response>

      In this case the S2/OGNL is 150x (!!!!!) slower than the JSTL/EL approach. Now clearly in this case the JSTL/EL approach can be used to get decent performance, but when using S2's Freemarker based tags that option isn't available.

      Attachments

        Activity

          People

            lukaszlenart Lukasz Lenart
            hyperion Matthew
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: