https://bz.apache.org/bugzilla/show_bug.cgi?id=64872

            Bug ID: 64872
           Summary: Inefficient enum resolution in JSPs
           Product: Tomcat 10
           Version: unspecified
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Jasper
          Assignee: dev@tomcat.apache.org
          Reporter: jeng...@amazon.com
  Target Milestone: ------

Our large public-facing application uses many custom JSP tags with enum
properties, for example:

<my:tag enumProperty="${'hotFudge'}"/>

The tag implements MyTag contains a corresponding property:

 public void setEnumProperty(MyEnum enumProperty)

and the enum looks like:

public enum MyEnum {
  hotFudge, whippedCream, cherries;
}

The compiled JSP performs the full resolution of 'hotFudge' -> MyEnum.hotFudge
on *every* request, even though the JSP compiler has enough information to
directly reference the enum.  This results in a significant amount of needless
work; profiling suggests it is around 10% of our JSP processing time.

Note that the same optimization applies when the datatype is a hard-coded
String (like above) or the datatype is boolean/Boolean.

Replacing these evaluations with direct references results in:
1. Lower cpu from not re-processing
2. Lower heap usage because the expression caches are smaller
3. Lower object creation rates because fewer helper objects are created
4. Possible error catching during JSP compilation: if someone refers to a
non-existent enum, that can be caught immediately.

-- 
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

Reply via email to