https://bz.apache.org/bugzilla/show_bug.cgi?id=69377
Bug ID: 69377 Summary: JSP optimization via custom code generation Product: Tomcat 9 Version: 9.0.x Hardware: All OS: All Status: NEW Severity: normal Priority: P2 Component: Jasper Assignee: dev@tomcat.apache.org Reporter: jeng...@amazon.com Target Milestone: ----- Similar to the older issue https://bz.apache.org/bugzilla/show_bug.cgi?id=64872 from 2020, there is an opportunity to improve performance via a narrow violation of the spec. As spec violations are not OK by default, an opt-in solution is required. If implemented correctly and activated, there can be significant performance improvements. In short, I would like to optimize my application by translating some <c:set/> calls into direct pageContext writes. For example, the current code: private boolean _jspx_meth_c_005fset_005f0(javax.servlet.jsp.PageContext _jspx_page_context) throws java.lang.Throwable { javax.servlet.jsp.PageContext pageContext = _jspx_page_context; javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut(); // c:set org.apache.taglibs.standard.tag.rt.core.SetTag _jspx_th_c_005fset_005f0 = new org.apache.taglibs.standard.tag.rt.core.SetTag(); _jsp_getInstanceManager().newInstance(_jspx_th_c_005fset_005f0); try { _jspx_th_c_005fset_005f0.setPageContext(_jspx_page_context); _jspx_th_c_005fset_005f0.setParent(null); // /WEB-INF/views/jsp/features/buybox/common/accordionDenarius.jsp(7,0) name = var type = java.lang.String reqTime = false required = false fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null _jspx_th_c_005fset_005f0.setVar("featureList"); // /WEB-INF/views/jsp/features/buybox/common/accordionDenarius.jsp(7,0) name = value type = javax.el.ValueExpression reqTime = true required = false fragment = false deferredValue = true expectedTypeName = java.lang.Object deferredMethod = false methodSignature = null _jspx_th_c_005fset_005f0.setValue(new org.apache.jasper.el.JspValueExpression("/WEB-INF/views/jsp/features/buybox/common/accordionDenarius.jsp(7,0) '${featureDefinition.subfeatures}'",_jsp_getExpressionFactory().createValueExpression(_jspx_page_context.getELContext(),"${featureDefinition.subfeatures}",java.lang.Object.class)).getValue(_jspx_page_context.getELContext())); int _jspx_eval_c_005fset_005f0 = _jspx_th_c_005fset_005f0.doStartTag(); if (_jspx_th_c_005fset_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { return true; } } finally { org.apache.jasper.runtime.JspRuntimeLibrary.releaseTag(_jspx_th_c_005fset_005f0, _jsp_getInstanceManager(), false); } return false; } can be reduced to: private boolean _jspx_meth_c_005fset_005f0(javax.servlet.jsp.PageContext _jspx_page_context) throws java.lang.Throwable { javax.servlet.jsp.PageContext pageContext = _jspx_page_context; pageContext.setAttribute("featureList", new org.apache.jasper.el.JspValueExpression("/WEB-INF/views/jsp/features/buybox/common/accordionDenarius.jsp(7,0) '${featureDefinition.subfeatures}'",_jsp_getExpressionFactory().createValueExpression(_jspx_page_context.getELContext(),"${featureDefinition.subfeatures}",java.lang.Object.class)).getValue(_jspx_page_context.getELContext())); return false } Not all invocations of c:set can be replaced this way, and certainly most tags cannot... however c:set is quite common and this substitution would eliminate object allocations, try/catch, instance manager work, etc. Coupled with other optimizations such as ELInterpreterTagSetters, the cost of setting a value can approach zero. It's hard to predict the runtime impact, however heap dumps from our application show that the most commonly-allocated standard tag is org.apache.taglibs.standard.tag.rt.core.SetTag, followed closely by WhenTag and IfTag. RemoveTag is likely to win as well, but we use it rarely. The request for this ticket is to build a mechanism for my application to override tag generation, based on the tag and its parameters. A non-standard default similar to StringInterpreterEnum would be gravy. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org