[
https://issues.apache.org/jira/browse/WW-4575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15044287#comment-15044287
]
zhouyanming commented on WW-4575:
---------------------------------
org.apache.struts2.views.freemarker.FreemarkerManager.java
{code:java}
protected ScopesHashModel buildScopesHashModel(ServletContext servletContext,
HttpServletRequest request, HttpServletResponse response, ObjectWrapper
wrapper, ValueStack stack) {
ScopesHashModel model = new ScopesHashModel(wrapper, servletContext,
request, stack);
// Create hash model wrapper for servlet context (the application). We
need one thread, once per servlet context
synchronized (servletContext) {
ServletContextHashModel servletContextModel =
(ServletContextHashModel) servletContext.getAttribute(ATTR_APPLICATION_MODEL);
if (servletContextModel == null) {
// first try a JSP support servlet. If it fails, default to
the servlet.
GenericServlet servlet = JspSupportServlet.jspSupportServlet;
if (servlet != null) {
servletContextModel = new ServletContextHashModel(servlet,
wrapper);
servletContext.setAttribute(ATTR_APPLICATION_MODEL,
servletContextModel);
} else {
servletContextModel = new
ServletContextHashModel(servletContext, wrapper);
servletContext.setAttribute(ATTR_APPLICATION_MODEL,
servletContextModel);
}
TaglibFactory taglibs = new TaglibFactory(servletContext);
servletContext.setAttribute(ATTR_JSP_TAGLIBS_MODEL, taglibs);
}
model.put(KEY_APPLICATION, servletContextModel);
model.putUnlistedModel(KEY_APPLICATION_PRIVATE,
servletContextModel);
}
...
}
{code}
synchronized on servletContext is very bad idea, we don't need singleton here,
creating duplicate servletContextModel is totally acceptable.
> Fix performance regression
> --------------------------
>
> Key: WW-4575
> URL: https://issues.apache.org/jira/browse/WW-4575
> Project: Struts 2
> Issue Type: Task
> Affects Versions: 2.3.20, 2.3.24
> Reporter: zhouyanming
> Fix For: 2.3.25
>
>
> I have an application run with struts2, recently I found my application
> performance downgraded if struts2 upgraded. a special use case:
> ab -n 3000 -c 150 http://localhost/login
> ||requests/second||struts2 version||
> |684|2.3.16|
> |515|2.3.18|
> |312|2.3.24|
> It's appreciatory if someon test with official example.
> I think struts2 should focus on performance improvement, make struts2 more
> configurable to deal with performance and security trade-off.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)