By Peter Bell

Objects, Frameworks and Performance

I've seen mention on various mailing lists of framework based OO apps that can take minutes to load the first time. I just want to clarify that depending on how much code you have it doesn't have to be this way . . .

I must preface this with saying that while I build apps of a reasonable size, they usually don't have very much physical code. I have fairly rich e-commerce applications which include content management, commerce and various custom features. One recent project had the following twenty business objects - each nominally with a service, dao and business object class file:

Address, SiteUser, Page, Press, User, ValueList, AuthenticationMethod, ProductCategory, Product, ProductAttribute, Order, OrderItem, DiscountCode, Photo, Report, address, CrossSell, Booking, TripType, PossibleTrip, Week

Of course, many applications are probably an order of magnitude larger than this, but it isn't a trivial application, it provides fairly rich functionality and on both my dev laptop and the production server it has never taken more than 2-3 seconds to reload the entire OO app in CF 8.01 with the default JVM.

I'm wondering if an additional benefit of code synthesis in ColdFusion may be that while there is the overhead of parsing XML and metadata at runtime, the vast majority of the CFC's and their methods don't exist?

Does anyone out there have an app with a first page load time of more than say 20-30 seconds and have any sense of how many CFC's you have, what is driving the load time, etc?

Comments
I do, in CF7. I've got a ton of singltons in the Application scope. (~150) They are all small objects but CF7 is slow to create them. CF8 its around 5 seconds I think.
# Posted By Anthony | 8/27/08 12:07 PM
what's really going to be interesting is seeing how much of a performance increase and loading time decrease these frameworks get when railo 3.1 ships. railo has always been faster and more efficient then adobe in the creation of objects. 3.1 is suppose to widen this mark further.
# Posted By dfguy | 8/27/08 12:22 PM
I got 130 bean definitions in my coldspring.xml file. 22 of them go through coldsprings AOP which I believe will double the amount of cfc's being created. I'm at 15 seconds load time with the model glue debugging turned on and with most beans being lazy. My start up time was almost 20 minutes before I moved to jdk1.6.0_10.
# Posted By Damien | 8/27/08 1:33 PM
@Anthony, Interesting - thanks for the data point

@dfguy, I think we can do pretty well with Adobe, but yeah - Railo is pretty impressive in terms of instantiation of cfcs - it's really nice!

@Damien, Wow - 20 minutes - that blows me away. Glad it's a little more reasonable now!
# Posted By Peter Bell | 8/27/08 1:53 PM
@Peter, this is an interesting thread and as I spend most of my time helping clients I am very interested in how you architecture things. It has been my belief for some time that a lot of initialization slowness comes from a misunderstanding of optimal architectures.
# Posted By Mike Brunt | 8/27/08 4:08 PM
Interesting! Perhaps we can share a "wee dram" in London next month and discuss further :-)

I currently have a code synthesis approach where most of the class files don't exist and most of the methods are described in xml and picked up using on onMissinMethod() style approach. My default assumption is that the performance of my approach would suck but that it would be an acceptable trade off for speed of development and ease of maintenance given most of my clients have low volume sites. I was in the middle of porting to a code generation solution with real cfc's and methods being generated pre-runtime to have a more conventional architecture - in part to have a more performant solution, but I'm now starting to wonder if the cost of all of the oMM() hits are less than the cost of the instantiation of all of the extra cfc's and methods given the way cfc's are compiled down to java objects. Who knows?!
# Posted By Peter Bell | 8/27/08 4:13 PM
@Peter aye re wee dram! Well I have two clients currently both of whom took a pre CFMX pre CFC
application and refactored it. One to mach-ii-coldspring-transfer the other to an in-house cfc based framework. In both cases the new apps are remarkably worse performance wise than the pre cfc based version. I suspect architectural issues in the new versions.
# Posted By Mike Brunt | 8/27/08 11:00 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.005.