Skip to main content
Participant
March 9, 2023
Question

createObject taking too long for cfc's after upgrade to 2021

  • March 9, 2023
  • 3 replies
  • 545 views

There is a custom code that create objects of a cfc (with almost 56 level of inheritance) using create object function, apparently its taking almost 10 to 13 mins to complete and causing the request to time out. We are using the JRE inside the Coldfusion 2021 with Java 11. The same code works fine with 2016 and Java 1.8 with almost 7 mins

 

Are there any limitation for level of inheritance when creating object with 2021 or anything to do with Java 11 with CF 2021

 

Any help will be much appreciated

 

 

    This topic has been closed for replies.

    3 replies

    Charlie Arehart
    Community Expert
    Community Expert
    March 10, 2023

    Ananthanaraya, while I can echo the sentiments of Dave and BKBK, in my work I help people who can't always "do the right thing" for whatever reason (cost, complexity, urgency,  shortsighted bosses, boredom, whatever).

     

    So I'll say that:

    • a) I'm not aware of any reason that cf2021 or Java 11 should inherently take twice as long.
    • But I'll note that b) there could be some difference between the two versions in how cf or the jvm is configured, which COULD impact the performance. You could do that compare or I could help you do it in minutes. 
    • It's also possible that c) some problem could be fixed by updating cf2021 and Java 11 to their latest updates. Again, you could consider/do that, or I could help you consider and do both in as little as 15 mins, with both easily reverted. 
    • Finally, d) if setting comparisons/updates did not help, I could show how to diagnose exactly where the slowness is, and then it should be possible to fix it--whether via code or config.

     

    I have presentations and blog posts on all the above (and of course much more) at carehart.org, if you may prefer to try to do all these things for yourself. 

     

    If you're interested in my direct remote help, you can learn more about my rates, approach, satisfaction guarantee, and more at carehart.org/consulting. That also offers a link to my online calendar, from which you can pick slots even today, or we can arrange time tomorrow even, if this is pressing for you. I suspect we could do the above and perhaps find the problem (if it remains) in as little as an hour. 

     

    Or we can try here to see what can be gained instead solely from back and forth among us all. Again, that problem should not be, and there should be a solution, short of a code rewrite (as wise as that may be--but perhaps you've got time and inclination to pursue that first). 

    /Charlie (troubleshooter, carehart. org)
    Ananthan!Author
    Participant
    March 16, 2023

    Thank you Charlie! even i think,  7 mins is not great, these are legacy code, written over the years :), before looking for any refactor, wanted to see if i am missing something; It worked when i reduce the level of inheritance to 2 (ofcourse first load was bit slow, didnt check the exact time) but its loaded. I even compared the jvm.config and fixed the white page due to the metaspace flag set in JVM, in  CF 2016

    Your blog posts are really helpful and i am reading that for many use cases 🙂 ; I will have to do these by myself for now and need to talk to my managers to see if they are okay to get consultant. 

    BKBK
    Community Expert
    Community Expert
    March 16, 2023

    Hi @Ananthan! ,

    As I said earlier, if you invest in refactoring the code now, you will be saving a lot of dollar$ in the long run. That is what I would insist to a manager.

     

    Now a technical note. Take a moment and look around you. What things do you see that you use regularly? Think about how you use them. 

     

    Were these things in use by someone who lived in the year 623 AD? Unlikely, right?

     

    Yet that is what your code is simulating. The year 623 AD is 56 generations ago, assming an average of 25 years per generation.

     

    You really should refactor. Try to reduce the depth of the inheritance tree to a single digit.

    BKBK
    Community Expert
    Community Expert
    March 10, 2023

    Why 56 levels of inheritance? That would very likely be poor design, even if you could instantiate the cfc in seconds. In any case a depth-of-inheritance-tree of 56 creates a lot of complexity.

    BKBK
    Community Expert
    Community Expert
    March 11, 2023

    @Ananthan! ,

    You mention a CFC instantiation time of 7 minutes as if that is a good thing. It is not.

     

    Think of a user waiting for the instantiated object to serve a request. Then you will realize that even one minute is too long.

     

    My earlier post identified a problem. Now, here's a suggestion for a solution:

    • Refactor the code to ensure that the depth of the inheritance tree is 6 or less.

     

    I have not chosen this number arbitrarily. Your code is used, maintained and extended by humans. In the lifetime of a piece of software, typically some 40 to 80 percent of the total costs will go to maintenance [see, for example, the chapter "The 60/60 Rule" in the book "97 Things every project manager should know"]

     

      The average human can juggle only 5 or so objects at a time in working memory. By reducing complexity you will be saving costs in the long run.

     

    Ananthan!Author
    Participant
    March 16, 2023

    Thank you BKBK! Yes, even i think,  7 mins is not great, these are legacy code, written over the years :), before looking for any refactor, wanted to see if i am missing something; It worked when i reduce the level of inheritance to 2 (ofcourse first load was bit slow, didnt check the exact time) but its loaded

    Community Expert
    March 10, 2023

    I don't have a great answer for this, other than I know it when I see it. And that's just too many objects.

     

    Seven minutes is not that great either, to be honest. I'd recommend you refactor this so that you don't have an unbroken chain of object creation that lasts seven minutes even if that works. That's a long time to take cycles away from concurrent users. Consider creating objects when you actually need them instead of beforehand.

     

    Dave Watts, Eidolon LLC

    Dave Watts, Eidolon LLC
    Ananthan!Author
    Participant
    March 16, 2023

    Thank you Dave! Yes, even i think,  7 mins is not great, these are legacy code, written over the years :), before looking for any refactor, wanted to see if i am missing something; It worked when i reduce the level of inheritance to 2 (ofcourse first load was bit slow, didnt check the exact time) but its loaded