1 Reply Latest reply on Feb 12, 2018 8:48 AM by Andrew Dinn

    Reducing Rule Helper instances

    Rajiv Shivane Newbie

      Hello Andrew and team:

       

      We are observing that one instance of our custom Rule Helper is created for every execution of the Rule. To reduce the GC burden, it would be nice if the Rule Helper instances could be reused. In our use case, most of our Rule Helpers could be singleton ... ie only one instance per Rule. We are not using any Bindings in our rules. 

       

      Would it be possible to implement some sort of reuse of the Helpers? 1. We could mark them as SINGLETON in the rule file, in which case byteman could call MyHelper.getInstance(Rule).helperMethod(<params>) or 2. We could mark the Helper in the rule file as STATIC, in which case byteman could look for static helper methods instead of instance methods.

      Along with the custom Helper, the InterpretedHelper instances should be reused. Since InterpretedHelper uses a bindingMap field, it appears that using static helper methods would mean that the Rules cannot have Bindings.

       

      Thoughts?!

       

      -Rajiv

        • 1. Re: Reducing Rule Helper instances
          Andrew Dinn Master

          Hi Rajiv,

           

          Sorry for the late reply -- for some reason I did not get a notification for this post and I only just saw it.

           

          I am afraid the creation of a helper instance is integral to the way Byteman operates. The helper carries the rule trigger context which is unique to each specific triggering of the rule.

           

          I am not sure why you are worried about GC costs. Normally helper instances only exist across the lifetime of the rule triggering (i.e. while the rule is being executed). In most cases that means they are allocated and die in the Eden GC space. This normally causes no significant memory overhead and merely implies that young GC collections happen with a very small increase in frequency.

           

          Do you have any measurements to suggest that GC costs are significantly increased because of Helper instance creation? Are you retaining handles on Helper instances across rule triggerings? I'd be happy to look into any problems you have found if you can provide me further details to see if I can advise on ways to avoid them.

           

          regards,

           

           

          Andrew Dinn