3 Replies Latest reply on Jun 17, 2011 10:53 AM by Wolf-Dieter Fink

    Call by value vs. call by reference

    Arbi Sookazian Master

      1) Where is this configured (i.e. which Jboss xml file)? 

      2) what is the default?


      3) what is the recommendation for a clustered Seam/JSF/RichFaces application wrt this?



      Performance note - Call By Value


      The use of  call by value and marshalling is very inefficient. It typically means

      method  invocations take 10 times the cpu. Why? Compare Call By Value with Call  By Reference


      Call By Reference

      1. caller does  ejb.someMethod()

      2. invocation is passed through  ejb container

      3. container does bean.someMethod()

      4. result is returned to the caller


      Call  By Value

      1. caller does ejb.someMethod()

      2. invocation is marshalled - the parameters are turned into  ObjectStream (a byte[])

      3. container  with a different classloader unmarshalls - byte[] ->  java Objects - including classloading

      4. invocation  is passed through ejb container

      5. container does  bean.someMethod()

      6. result is marshalled - the  return value is turned into ObjectStream

      7. result  is unmarshalled using the caller's classloader - byte[] -> java Object

      8. result is return to the  caller


      The marshalling and unmarshalling uses a lot of cpu.


      from: http://community.jboss.org/wiki/ClassLoadingConfiguration

        • 1. Re: Call by value vs. call by reference
          Arbi Sookazian Master

          There is a EJBDeployer MBean I see in the JMX console.  The value for CallByValue is false.


          So I'm assuming all EJB calls for all apps are call-by-reference semantics?  How do you configure call-by-reference on an app level (i.e. some apps call-by-value and some call-by-reference)?


          What is the approx. performance benefit of doing this (we're skipping the marshalling/unmarshalling now)?

          • 2. Re: Call by value vs. call by reference
            Jens Augustsson Newbie

            1) file [JBOSS_HOME]/[CONF]/jboss-service.xml, MBean name="jboss:service=Naming", <attribute name="CallByValue">

            2) standard configuration is "true", all others configurations (default, all, web, standard) uses "false"

            3) Since the cluster configuration defaults to "false", I'd keep this value as is - thus use Call By Reference. The Spec mandates the opposite, but I don't see why we wouldn't wanna let JBoss optmize /inVM/ calls.




            • 3. Re: Call by value vs. call by reference
              Wolf-Dieter Fink Master

              As Jens say the SPEC conform way is call-by-value.

              If you use the standard server configuration it will be so configured.


              But it is a performance improvment if you use call-by-reference for the duration, because of serialization. Also the througput is better because of unburden the GC.

              If you keep the behaviour in mind I see no issue why you should not use call-by-reference.