4 Replies Latest reply on Feb 25, 2002 6:06 AM by Trevor Squires

    What is *up* with invokes on an empty domain????

    Trevor Squires Novice

      Adrian,

      I really don't get this. DynamicMBean invokes on an empty domain take up to twice as long as non-empty domains according to the perf tests.

      Figuring something was wrong I changed the BasicMBeanRegistry constructor to do this:

      this.defaultDomain = defaultDomain;
      HashMap defdom = new HashMap();
      domainMap.put(defaultDomain, defdom);
      domainMap.put("", defdom);

      and removed the

      if (domain.length() == 0) domain = defaultDomain;

      test from get(). By the way I know that breaks other stuff, I just wanted to see what happened on invokes.

      Maybe I'm braindead but with that code I would have expected empty domain invokes to be *faster* but it's no better.

      This is really odd. I hate not understanding what's going on.

      Trev

        • 1. Re: What is *up* with invokes on an empty domain????
          Trevor Squires Novice


          Ok, I found the problem. It's with our perftests and unfortunately it means that numbers are going to get slightly worse across the board.

          In the tests we are using the same ObjectName instance for registration and invokes. This means that when we lookup the objectname in the registry the string.equals() methods are benefitting from a shortcut in String which returns true if strings are *reference* equivalent (which they are).

          Whew. At least I understand what's happening now.

          Trev

          • 2. Re: What is *up* with invokes on an empty domain????
            Adrian Brock Master

            Trevor,

            Each of these is 10,000,000 invocations
            averaged over 3 tests

            "Test".hashCode()
            160 ms

            "".hashCode()
            310 ms

            "Test".equals("Another");
            305 ms

            "".equals("Another");
            270 ms

            "Test".equals("Test");
            160 ms

            "".equals("");
            150 ms

            "Test".equals("Test");
            "Test".equals("Another");
            401 ms

            "".equals("");
            "".equals("Another");
            400 ms

            It looks like it always calculates the hashCode
            for "" and caches everything else.

            Where are we using "".hashCode() ?
            I don't see it :-(

            Regards,
            Adrian

            • 3. Re: What is *up* with invokes on an empty domain????
              Adrian Brock Master

              Crossed in the post :-)

              What numbers do you get RI/JBoss?

              Caching ObjectName instances is a valid optmization,
              but we need to test both.

              Regards,
              Adrian

              • 4. Re: What is *up* with invokes on an empty domain????
                Trevor Squires Novice

                WRT the "" hashcode calculation always happening - that's because String.hashCode() caches the hash as an int and only calculates it if it's 0. For "" it's always 0 so it always calculates.

                As for caching ObjectNames - the only way to guarantee fast lookups on a cached objectname is if you cached the one stored in the registry. The only way to get that one is by querying the MBeanServer for the ObjectInstance.

                It's a valid optimisation and it will save time but only about a second per *million* invokes on my machine.

                I think the rest of JBoss will only notice that for a million invokes the RI takes about 70 seconds while we will take something like 5 or 6 seconds.

                I think in JDK1.4 the comparison will be about 25 seconds for the RI and about 3 seconds for us.

                Trev