Uploaded image for project: 'Javassist'
  1. Javassist
  2. JASSIST-163

RuntimeSupport.find2Methods a perf hotspot when proxy's methods are called at higher concurrency

    Details

    • Type: Enhancement
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 3.15.0-GA, 3.16.1-GA
    • Fix Version/s: 3.17.0-GA
    • Labels:
      None

      Description

      We've been profiling our Hibernate 3.6.10-based app and noticed a perf bottleneck in javassist.util.proxy.RuntimeSupport.find2methods. Unfortunately, this method, which has a synch. block, is being called on
      every invocation of every proxied entity method (see javassist.util.proxy.ProxyFactory.makeForwarder(), called indirectly by
      ProxyFactory.createClass()).

      In our testing, the result is that our service call's latency increases from 33 to 55, 260, 400ms as concurrency increases
      1-10-20-30 users on a 4-core CPU. At 20 and 30 users 51% of CPU time is spent contending for a monitor in RuntimeSupport.find2methods:

              synchronized (methods) {
                  if (methods[index] == null) {
                      methods[index + 1] = thisMethod == null ? null
                                           : findMethod(self, thisMethod, desc);
                      methods[index] = findSuperMethod(self, superMethod, desc);
                  }
              }
      

      Since find2methods merely interrogates class metadata, seems like its return values should be cached (in a ConcurrentMap?) instead of repeatedly executing the above synchronized statement. Instead, currently, it's being called every time a proxied method is executed - see Invocation Count in this screen shot:
      https://issues.jboss.org/secure/attachment/12353025/monitor-backtraces.png

      Full YourKit profile is attached as a ZIP archive; key screen shots from the snapshot also attached separately

        Gliffy Diagrams

          Attachments

          1. Bean_$$_bulkaccess_0_Two.txt
            13 kB
          2. Bean_$$_bulkaccess_0.txt
            13 kB
          3. blocked-threads.png
            blocked-threads.png
            134 kB
          4. BulkAccessorFactory.java.diff
            3 kB
          5. BulkAccessorFactory.java.diff2
            3 kB
          6. BulkAccessorFactory.patch
            2 kB
          7. find2methods-hotspot.png
            find2methods-hotspot.png
            147 kB
          8. jassist-163-fix.patch
            16 kB
          9. monitor-backtraces.png
            monitor-backtraces.png
            118 kB
          10. monitor-backtraces.png
            monitor-backtraces.png
            137 kB
          11. Product_$$_javassist_0.java
            6 kB
          12. Product_$$_javassist_0-post-patch.java
            6 kB
          13. Product.java
            1 kB
          14. Tomcat-2012-03-28(2).zip
            7.16 MB

            Issue Links

              Activity

                People

                • Assignee:
                  chiba Shigeru Chiba
                  Reporter:
                  nikita.tovstoles Nikita Tovstoles
                • Votes:
                  2 Vote for this issue
                  Watchers:
                  11 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: