Techleadz Team
Techleadz Team

Reputation: 318

ColdFusion 11 taking too much time to compile CFC

I am working on ColdFusion 11. I have a CFC file which has 20,000 line of code. Whenever I make any change in the CFC file it takes 15-20 seconds to compile. This issue doesn't occur with smaller files, like 5,000 line of code.

Is anyone else facing this issue? Do I need to reduce the file size? If yes, please suggest a solution.

Upvotes: 2

Views: 368

Answers (2)

Adrian J. Moreno
Adrian J. Moreno

Reputation: 14859

I have a CFC file which has 20,000 line of code.

That's cute. :) My previous employer has CFCs w/ 50k lines of code and more. So much that we had to <cfinclude> code into the CFCs so that Java could even compile them.

I am not talking about the page performance I am talking about the compile time. Whenever I made any change it takes 20 seconds to open the page otherwise page performance is okay.

To be clear, are you talking about loading a URL in the browser takes a lot of time after changing the CFC or opening the file in your editor?

I am using notepad++ and Dreamweaver.

Neither of these will handle large files like you have. Long ago, I used the Eclipse IDE w/ CFEclipse to edit CFML files. That IDE cannot handle large file sizes without adjusting memory settings. CF Builder has the same problem.

We converted all developers at that company to Sublime Text with the CFML plugin (literally deleted DreamWeaver from their machines). That was the only editor that could handle files of that size. You can alternately try using VS Code, which also has a CFML plugin, but I've not personally used it w/ those large files before.


Update

Since you're talking about the page load speed in the browser, once the change has been made to the CFC, the first page load that calls that CFC will compile it to a Java class file which gets cached by the server. The next page load will reference the compiled Java class and should be faster by a (sometimes) negligible amount. If the CFC is not cached in your application scope, then the object has to be created in memory with each page load, but that shouldn't take very long, especially in post-CF-9 versions of Adobe CF.

If your page load is slow, turn on debugging and figure out where your bottleneck actually exists. You've got a slow query, too many queries, too large loops, trying to fetch and render too much data or something else that's slowing things down.

Upvotes: 2

Alex
Alex

Reputation: 7833

I can confirm your observation. Compiling CFML to Bytecode can take quite some time. Your only option to minimize the noise on every code change in development, is by reducing the complexity of your component and split it into multiple sub components. To be honest with you: 20k lines of code sounds like a God object to me. Consider separating functionalities and inject dependencies. This will reduce the need to compile everything all over again and instead only compile sub components you actually changed. Only you can tell how to refactor your code though. Good luck.

Upvotes: 3

Related Questions