4 Replies Latest reply on Jul 2, 2004 6:23 PM by Elias Ross

    mbean invocation performance

    Anthony Newbie

      I'm doing some performance analysis in preparation for using JBoss/MX as our server backbone. I'm seeing throughput of about 70k mbean invocations / sec. Is that reasonable?

      By way of comparison, I can get 4M invocations/sec with a direct method invocation, though I'm still not sure if I've competely fooled the optimizer.

      The test case uses standard mbeans with a depends-optional-attribute setter. How can I make it go faster?

      jbosss 3.2.4, win2k, jdk 1.4.2, P4 1.5GHz

        • 1. Re: mbean invocation performance
          Anthony Newbie

          Ok, so further investigation shows a fairly constant overhead of about 15-25 microsecs per invocation using standard mbeans. I've seen references to over 1M invocations/sec here:

          http://www.samspublishing.com/articles/article.asp?p=27196&seqNum=4

          What do I need to do to get that kind of performance?

          What is the downside of exposing a shortcut like getDirectRef() and doing direct invocations rather than going through the mbean proxy?

          TIA

          • 2. Re: mbean invocation performance
            Anthony Newbie

            Here's the code in question...

            jboss-service.xml:



            hello


            no hands
            <depends optional-attribute-name="HelloWorld" proxy-type="attribute">my.hello:service=hw1




            HelloWorldMBean.java:

            package hello;

            import org.jboss.system.ServiceMBean;
            public interface HelloWorldMBean extends ServiceMBean {
            public void setMessage(String msg);
            public void sayHi();

            public void setHelloWorld(HelloWorldMBean hello);
            public HelloWorldMBean getDirectRef();
            public void echo();
            }


            HelloWorld.java:

            package hello;

            import org.jboss.system.ServiceMBeanSupport;
            public class HelloWorld extends ServiceMBeanSupport implements HelloWorldMBean {

            private double r;
            private double incr = 1.7d;

            private String message;
            private HelloWorldMBean hello;

            public HelloWorldMBean getDirectRef() {
            return this;
            }

            public void setMessage(String msg) {
            message = msg;
            }

            public void sayHi() {
            r += Math.random() / incr;
            }

            public void setHelloWorld(HelloWorldMBean hello) {
            this.hello = hello;
            }

            public void echo() {
            hello.sayHi();
            }

            protected void startService() {
            log.info("Starting " + message);
            if (hello != null) {
            double t1 = testEcho();
            log.info("invoke ms " + t1 / 1000000.0);
            }
            }

            protected void stopService() {
            log.info("Stopping " + message);
            }

            private double testEcho() {

            for (int i = 0; i < 50000; i++) {
            hello.sayHi();
            }

            long start = System.currentTimeMillis();
            for (int i = 0; i < 1000000; i++) {
            hello.sayHi();
            }
            long elapsed = System.currentTimeMillis() - start;
            double rate = (1000000 * 1000.0 / elapsed);
            log.info("jmx " + rate);

            return elapsed;
            }
            }

            • 3. Re: mbean invocation performance
              Elias Ross Master


              You can return a POJO through a "getRef" method, including the MBean interface itself. Example:

              HelloMBean h = MBeanServer.getAttribute(name, "Ref")


              If you are doing something like this, it should be plenty fast:

              Object args[] = { a, b, c};
              String sig[] = "java.lang.Object", ...
              while (true)
               getServer().invoke(name, args, sig);
              


              If you're going over RMI it's slower, it's also slower to construct the args/sig arrays each invocation. Java 1.4 is a lot faster with Reflection.


              • 4. Re: mbean invocation performance
                Elias Ross Master


                You can set the system property

                jbossmx.optimized.dispatcher

                to "true". I don't know if it's officially supported in JBoss, however.

                Check out ./src/main/org/jboss/mx/capability/DispatcherFactory.java in the JMX source.