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

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

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: 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.

        Attachments

        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

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: