6 Replies Latest reply on Jun 15, 2007 1:00 PM by David Lloyd

    Performance problem in VFS

    David Lloyd Master

      I was testing the jBPM web console inside of AS 5.0.0.Beta2 and I found a performance issue. It was taking around 40-50 seconds for my first request to come back, so I hooked up a profiler and discovered something interesting.

      A significant fraction of this time is spent constructing really a lot of Logger instances (about 40,000-90,000 per Facelets taglib, looks like). The problem class is org.jboss.virtual.plugins.context.AbstractVirtualFileHandler, which creates a logger as an instance variable:

      protected Logger log = Logger.getLogger(getClass());
      


      Presumably so that when messages are logged, they're associated with the implementation class. Still waiting for my profiler to finish, but so far, 2,225,108 instances of Logger have been constructed. That's a lot. This isn't the top item on the list of hot spots, but it's up in the top 15 or so.

      The loggers should be made static. If this kind of per-class logger behavior is desired, how about using an abstract getLogger() method which initialized a protected log field on the base class.


        • 1. Re: Performance problem in VFS
          David Lloyd Master

          Worth mentioning that of the 3,138,677 times that org.jboss.logging.Logger.getLogger() has been called, 3,133,812 came from org.jboss.virtual.plugins.context.AbstractVirtualFileHandler..

          • 2. Re: Performance problem in VFS
            Ales Justin Master

             

            "david.lloyd@jboss.com" wrote:

            The loggers should be made static. If this kind of per-class logger behavior is desired, how about using an abstract getLogger() method which initialized a protected log field on the base class.


            What about if you changed this temp and try to run it again?
            I can prepare a patch for you to try, just let me know.

            • 3. Re: Performance problem in VFS
              David Lloyd Master

               

              "alesj" wrote:
              What about if you changed this temp and try to run it again?


              I just replaced the logger with a simple static one and so far, the results are dramatically better. Don't have numbers yet though.

              How important is it to have the logger name set to the concrete class for these classes? If it's very important, I can put in an abstract method to grab a static logger from the concrete class. Or you can. :-)

              • 4. Re: Performance problem in VFS
                David Lloyd Master

                Looks like the logger creation, which was high up on the hot spots list, is now completely gone from that list. I'd call it a win.

                • 5. Re: Performance problem in VFS
                  Scott Stark Master

                  Just make it static. If subclasses need a different logger name they can add their own static instance as well.

                  • 6. Re: Performance problem in VFS
                    David Lloyd Master

                    I don't have commit access. But someone who does can merge this patch:

                    Index: src/main/java/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java
                    ===================================================================
                    --- src/main/java/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java
                    +++ src/main/java/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java
                    @@ -53,7 +53,7 @@
                     public abstract class AbstractVirtualFileHandler implements VirtualFileHandler
                     {
                     /** The log */
                    - protected Logger log = Logger.getLogger(getClass());
                    + protected static final Logger log = Logger.getLogger(AbstractVirtualFileHandler.class);
                     /** serialVersionUID */
                     private static final long serialVersionUID = 1L;
                     /** The class serial fields */
                    @@ -397,7 +397,5 @@
                     this.context = factory.getVFS(rootURI);
                     this.references = new AtomicInteger(0);
                     this.vfsUrl = (URL)fields.get("vfsUrl", null);
                    - // Restore the log
                    - log = Logger.getLogger(getClass());
                     }
                     }