Struts 2
  1. Struts 2
  2. WW-3750

ScopesHashModel calls OgnlValueStack.findValue too many times during rendering freemarker templates

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.1.1
    • Fix Version/s: 2.3.3
    • Component/s: Value Stack
    • Labels:
    • Flags:
      Patch

      Description

      I saw using a profiler, that OgnlValueStack.findValue(String) gets called about a thousand times during rendering a page. Most of the calls are coming from ScopesHashModel.
      All freemarker templates contain a lot of references to e.g. "parameters". This variable is evaluated in ScopesHashModel over and over again, which takes about 10% time of total page load.
      I think we can assume, that the top-level objects on the value stack will not change during rendering a single struts2 tag. So with a little caching, we can eliminate most of the findValue method calls.

      In my application I tested this modification and didn't notice any side effects or bugs. The OgnlValueStack.findValue(String) calls on a test page went down from a thousand to a hundred. This improved overall page rendering time from about 400ms to 360ms.

      Patch is attached.
      Please review it.

      1. WW-3750-parameters.diff
        2 kB
        Pelladi Gabor
      2. WW-3750-2.diff
        2 kB
        Pelladi Gabor
      3. WW-3750.diff
        1 kB
        Pelladi Gabor

        Issue Links

          Activity

          Lukasz Lenart made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Lukasz Lenart made changes -
          Fix Version/s 2.3.3 [ 12320642 ]
          Fix Version/s 2.3.2 [ 12319199 ]
          Lukasz Lenart made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Pelladi Gabor made changes -
          Attachment WW-3750-parameters.diff [ 12519070 ]
          Lukasz Lenart made changes -
          Link This issue breaks WW-3776 [ WW-3776 ]
          Lukasz Lenart made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Johannes Geppert made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Johannes Geppert made changes -
          Assignee Johannes Geppert [ jogep ]
          Pelladi Gabor made changes -
          Attachment WW-3750-2.diff [ 12512105 ]
          Lukasz Lenart made changes -
          Fix Version/s 2.3.2 [ 12319199 ]
          Pelladi Gabor made changes -
          Field Original Value New Value
          Attachment WW-3750.diff [ 12512096 ]
          Pelladi Gabor created issue -

            People

            • Assignee:
              Johannes Geppert
              Reporter:
              Pelladi Gabor
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development