We are in the process of upgrading from ColdFusion 9 to ColdFusion 2016 and we have noticed an overall decrease of performance. We ran several simulations to give more insight. Below is a script that gives a good example of the performance decrease. The script builds a query and then creates a structure from the query.
<!--- Machine info --->
<cfset runtime = createObject("java", "java.lang.System")>
<cfset props = runtime.getProperties()>
<cfset env = runtime.getenv()>
<Cfoutput>
coldfusion: #SERVER.ColdFusion.ProductVersion# #SERVER.ColdFusion.ProductLevel#<br>
java.version: #props["java.version"]#<br>
java.vm.name: #props["java.vm.name"]#<br>
os.name: #props["os.name"]#<br>
PROCESSOR_IDENTIFIER: #env["PROCESSOR_IDENTIFIER"]#<br>
PROCESSOR_ARCHITECTURE: #env["PROCESSOR_ARCHITECTURE"]#<br>
NUMBER_OF_PROCESSORS: #env["NUMBER_OF_PROCESSORS"]#<br><Br>
</Cfoutput>
<!--- Create a query --->
<cfset myQuery = QueryNew("Name, Time, Advanced", "VarChar, Time, Bit")>
<cfset testQuery = QueryNew("ColumnA,ColumnB,ColumnC,ColumnD,ColumnE,ColumnF,ColumnG,ColumnH,ColumnI,ColumnJ,ColumnK,ColumnL,ColumnM,ColumnN","VarChar,VarChar,VarChar,VarChar,VarChar,VarChar,VarChar,VarChar,VarChar,VarChar,VarChar,VarChar,VarChar,VarChar")>
<!--- Populate the query --->
<Cfloop from=1 to=300 index="x">
<cfset QueryAddRow(testQuery, 1)>
<cfloop index="intLetter" from="#Asc('A')#" to="#Asc('N')#" step="1">
<cfset temp = QuerySetCell(testQuery, "Column#chr(intLetter)#", "Row #x# column #intLetter#", x)>
</cfloop>
</cfloop>
<Cfset init = GetTickCount()>
<!--- Query to structure --->
<Cfset queryToStruct = structNEw()>
<cfloop query="testQuery">
<Cfset init2 = GetTickCount()>
<cfset queryToStruct[testQuery.currentrow] = structNew()>
<cfset queryToStruct[testQuery.currentrow]['ColumnA'] = structNew()>
<cfloop list="#testQuery.columnList#" index="key">
<cfset queryToStruct[testQuery.currentrow]['ColumnA'][testQuery[key][testQuery.currentrow]] = testQuery[key][testQuery.currentrow]>
</cfloop>
<cfoutput>#x#:#GetTickCount()-init2#<br></cfoutput>
</cfloop>
<cfoutput>-----------<br><b>#GetTickCount()-init#</b><br><br><Br></cfoutput>
<!---Cfdump var=#queryToStruct# --->
We have two servers with the exact same hardware configuration. One server is running on Windows 2008 / ColdFusion Server 9 Enterprise (Java version 1.6.0_14) and the other one is running on Windows 2016 / ColdFusion 2016 Standard (Java version 1.8.0_112). Both ColdFusion servers have the same Minimum JVM Heap Size (5024 MB) and Maximum JVM Heap Size (5048 MB).
The performance on the ColdFusion 9 server is more then 4x faster. Can someone give an explanation of why this is happening and how to solve this?
Update
To rule out any other process that would slow down ColdFusion I installed ColdFusion 9, ColdFusion 11 and ColdFusion 2016 all on the same virtual machine and all using the built in web server. Default installation settings. The outcome: ColdFusion 9 is fastest, followed closely by ColdFusion 11. ColdFusion 2016 is much slower.
Update 2 Made some changes to the script, so it is more clear what this script is doing.
Update 3 The results can be viewed here: http://136.144.177.152/test2.asp or http://136.144.177.152/test-toma.asp or http://136.144.177.152/test-ag.asp Note that the code is actually processed, so each time you load the page the results differ slightly.
Also i would like to point out i am not trying to optimize this code. I tried to make a very simple reproducible example. The sole purpose is to point out the difference in performance and find a reason and a solution.
Update 4 Did some extra testing and found the potential problem. For some reason the following code is very slow on coldfusion 2016 / Windows 2016 :
<cfset tmp = testQuery['ColumnA'][testQuery.currentrow]>
What i found very strange is that updating the query value is not slow. E.g.
<cfset testQuery['ColumnA'][testQuery.currentrow] = key>
All results can be found here: http://136.144.177.152/test5.asp or http://136.144.177.152/test6.asp. I also installed coldfusion 2016 on my laptop and found no performance issues. I also tried installing coldfusion 2016 on windows 2012 machine. Here i found the same performance issues.
Update 5 Based on Tomalak suggestion I removed the indexed access notation. This clearly is a performance issue on coldfusion 2016. Actual results can be found here http://136.144.177.152/bug-adobe.asp. I opened a bug at adobe for this issue here https://tracker.adobe.com/#/view/CF-4201966.
Evaluate()
call. – Foliar<cfloop>
tags. When I put the inner<cfloop list="#testQuery.columnList#" index="key">
into a separate function and simply call that function in the<cfloop query="testQuery">
, things speed up significantly on my CF2016. – FoliarqueryToStruct
code doesn't make any sense, really. Please fix that code first, or explain what it should do. – Foliar