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

            Bug ID: 69419
           Summary: Redundant code execution in nested
                    ApplicationHttpRequest
           Product: Tomcat 9
           Version: 9.0.x
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: jeng...@amazon.com
  Target Milestone: -----

Created attachment 39916
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=39916&action=edit
Patch for 9.x

JSP inclusions wrap the current ServletRequest in a new ApplicationHttpRequest;
nested inclusions therefore result in nested chains of ApplicationHttpRequests.
 In our large, etc. application, this nesting ranges from 1 - 7 layers deep
before disappearing from our data (meaning: 8+ exists but it's extremely rare).

Any access to the request is handled first by the outermost
ApplicationHttpRequest, then delegated to each item in the chain until it
finally reaches the original, unwrapped request.  This unfortunately means that
the expensive logic for identifying special values is executed for each nested
layer, with the same result each time.

The attached patch file implements a fast-path that is used when delegating to
a nested instance, eliminating both the duplicate special logic and many
embedded virtual method lookups.  The patch includes the change, a speed test
(added to TesterApplicationHttpRequestPerformance), and a JUnit test (added to
TestApplicationHttpRequest).  Performance as observed on my machine:


Before: 
Depth 0: 970930633ns
Depth 1: 1175171009ns
Depth 4: 1950073374ns
Depth 7: 3441997543ns

After:
Depth 0: 970601794ns
Depth 1: 1210693988ns
Depth 4: 1420921877ns
Depth 7: 1831309561ns

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