[ https://issues.apache.org/jira/browse/WW-3750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13232514#comment-13232514 ]
Lukasz Lenart edited comment on WW-3750 at 3/19/12 10:14 PM: ------------------------------------------------------------- This patch has a side effect on how <#list> (<#foreach> and so on) are working in Freemarker templates. Take a look on the exercise below from the config-browser plugin. With patch in place, ${showConfig} expression will be evaluated only once throughout the Stack and the returned value will always be the same. {code:html} <#list actionNames as name> <@s.url id="showConfig" action="showConfig" includeParams="none"> <@s.param name="namespace">${namespace}</@s.param> <@s.param name="actionName">${name}</@s.param> </@s.url> <li><a href="${showConfig}">${name}</a></li> </#list> {code} was (Author: lukaszlenart): This patch has a side effect on how <#list> (<#foreach> and so one) are working in Freemarker templates. Take a look on the exercise below from the config-browser plugin. With patch in place, ${showConfig} expression will be evaluated only once throughout the Stack and the returned value will always be the same. {code:html} <#list actionNames as name> <@s.url id="showConfig" action="showConfig" includeParams="none"> <@s.param name="namespace">${namespace}</@s.param> <@s.param name="actionName">${name}</@s.param> </@s.url> <li><a href="${showConfig}">${name}</a></li> </#list> {code} > ScopesHashModel calls OgnlValueStack.findValue too many times during > rendering freemarker templates > --------------------------------------------------------------------------------------------------- > > Key: WW-3750 > URL: https://issues.apache.org/jira/browse/WW-3750 > Project: Struts 2 > Issue Type: Improvement > Components: Value Stack > Affects Versions: 2.3.1.1 > Reporter: Pelladi Gabor > Assignee: Johannes Geppert > Priority: Minor > Labels: patch, performance > Fix For: 2.3.2 > > Attachments: WW-3750-2.diff, WW-3750.diff > > > 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. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira