Ask a Question related to Coldfusion Database Access, Design and Development.
-
FattyMatty #1
CFFILE Slower in MX
Attached is 'testwrite.cfm' which demonstrates the problem. Be sure to set the
'root' parameter before running the application.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test File Write </title>
</head>
<body>
<!--- Be sure to set the 'root' parameter in the next line with the correct
drive letter for the server where you have write privledges. --->
<!--- Sample times for this test
CF 4X 9094 ms
CF 6 base install 127109 ms
CF6 Updater 2 410500 ms
--->
<CFSET root = "e:\ots1dcin5\wwwroot\downloads">
<CFSET ExportedFile = ''>
<CFSET start = GetTickCount()>
<CFSET SavedDateTime = #DATEFORMAT(#NOW()#, "MMM DD YYYY")# & " " &
#TIMEFORMAT(#NOW()#, "h:mmTT")#>
<CFSET TEXTPUTPUT = "">
<CFSET OUTFILE = "#root#\Test_Export.csv">
<CFSET ExportedFile = ExportedFile & OutFile & "<P>">
<CFIF #FILEEXISTS(OUTFILE)# is "YES">
<cffile action="DELETE" file="#OUTFILE#">
</CFIF>
<CFSET TheOrderNumber = 1>
<CFSET COUNT = 0>
<cfloop index="i" from="1" to="4000" step="1">
<CFIF COUNT EQ "0">
<CFSET TEXTOUTPUT = "This is a line of text to simulate that we have
written a complete record to the database and that another line will be written
next.">
<CFSET SavedDateTime = #DATEFORMAT(#NOW()#, "MMM DD YYYY")# & " " &
#TIMEFORMAT(#NOW()#, "h:mmTT")#>
<CFELSE>
<CFSET TEXTOUTPUT = "This is Another line of text to simulate that we have
written a complete record to the database and that another line will be written
next.">
</CFIF>
<CFSET end = GetTickCount()>
<CFSET time = Evaluate( end - start)>
<CFIF #FILEEXISTS(OUTFILE)# is "YES">
<CFSET FileDere = 0>
<CFELSE>
<CFSET FileDere = 1>
</CFIF>
<CFIF FILEDERE EQ 1>
<CFTRY>
<cffile action="WRITE" file="#OUTFILE#" output="#TEXTOUTPUT#"
addnewline="Yes">
<cfcatch type="Any">
<CFTRY>
<cffile action="WRITE" file="#OUTFILE#" output="#TEXTOUTPUT#"
addnewline="Yes">
<cfcatch type="Any">
<CFTRY>
<cffile action="WRITE" file="#OUTFILE#" output="#TEXTOUTPUT#"
addnewline="Yes">
<cfcatch type="Any">
<CFTRY>
<cffile action="WRITE" file="#OUTFILE#" output="#TEXTOUTPUT#"
addnewline="Yes">
<CFCATCH>
<script language="JavaScript" type="text/javascript">
{
alert('The Website Export file is currently in use.\n\nPlease try
again later.'); window.navigate('http://ots1dcpi3/admin/');
}
</script>
<CFABORT>
</CFCATCH>
</CFTRY>
</CFCATCH>
</CFTRY>
</cfcatch>
</cftry>
</CFCATCH>
</CFTRY>
<CFELSE>
<cffile action="APPEND" file="#OUTFILE#" output="#TEXTOUTPUT#"
addnewline="Yes">
</CFIF>
<CFSET COUNT=COUNT+1>
</CFLOOP>
</body>
</html>
FattyMatty Guest
-
Sound slower than video
The sound falls behind the video on our player. Here is the link: http://www.ssdk9.com/content/downloads/ How can we fix this problem?? Help... -
MX 7 upgrade slower?
I just upgraded from 6.1 to 7. The pages work. The pages load slower ... especially the graphics. This slowness is true for CFM, HTM and ASP pages!... -
7.4.6 FC2 MUCH slower from 2.6.9-1.11 to 2.6.10-1.8
31 minutes in 2.6.10-1.8: select kstime(), update_ranking_usuarios(), kstime(); kstime | update_ranking_usuarios | kstime... -
6.1, Even slower!!!!
I just installed the 6.1 updater hoping that the MM claims of performance boost were correct. Wrong, running OS-X .2.6, it runs even slower than it... -
XP running slower than it use to
I know there could be a plethora of reason for the slow down but I do not know how to speed things up. Basically XP takes some to to load whera... -
JMGibson3 #2
Re: CFFILE Slower in MX
I can't speak to the version disparity, I'm only on 4.5.1 SP2 myself.
I did notice that you're using ACTION="APPEND". I discovered once upon a time
that this is grotesquely inefficient. Apparently each action causes an OPEN of
the file, a Read the entire file into memory, add the line to the memory
version, Write the entire file from memory, Close the file, and free memory.
So I/O, memory, and to a certain extent CPU, wise, the 100th APPEND is doing
100 times the work of the 1st, the 101st, 101 times the work, etc. This will
obviously be compounded by any I/O (networked drives), or memory
performance/swapping/thrashing (Hard Memory vs. chewed up by running processes
vs. Virtual Memory) considerations on the various platforms.
If it's small enough to get away with it, build the entire output set into one
huge variable and ACTION=WRITE it once when finished.
I had one application that simply had to use APPEND. I went to the extreme
of:
1. Writing to the C: drive and ACTION=MOVE'ing it to it's final destination
at end of job.
2. Emulate the old Mainframe blocking concept to only append every 100 at a
time, attached if interested (it should dramatically speed up all times,
perhaps alleviating the disparity):
<!--- Output Blocking parameters since CFFILE Append is grotesque --->
<cfset blkCTR = 0>
<cfset blkMax = 100>
<cfset varBlk = "">
<cfset var0A = chr(10)> <!---Decimal 10 = Hex 0A --->
<cfset var0D = chr(13)> <!---Decimal 13 = Hex 0D --->
<cfset varNL = var0D & var0A><!--- = Hex 0D0A --->
<cfset wrkFileName = "C:\action_export_Rolls_#TimeFormat(Now(),"hhmmss" )#.txt">
<CFOUTPUT query="getRolls">
Builds a varText line for each row
<!--- CFFILE seems grossly inefficient on Appends
probably opening it into core each time.
Let's try "blocking" the writes --->
<cfif blkctr GT blkMax>
<CFFILE ACTION="Append" FILE="#wrkFileName#" OUTPUT="#varBlk#"
ADDNEWLINE="No">
<cfset blkCtr = 0>
<cfset varBlk = "">
</cfif>
<cfset blkCtr = blkCtr + 1>
<cfset varBlk = varBlk & varText & varNL>
</CFOUTPUT>
<!--- Write the last block --->
<CFFILE ACTION="Append" FILE="#wrkFileName#" OUTPUT="#varBlk#" ADDNEWLINE="No">
<CFFILE ACTION="Copy" SOURCE="#wrkFileName#" DESTINATION="#expFileName#"><!---
Final Destination --->
<CFFILE ACTION="Delete" FILE="#wrkFileName#">
JMGibson3 Guest
-
FattyMatty #3
Re: CFFILE Slower in MX
I agree there are more efficient ways. Howerver, I still would like to
determine if CFFILE is slower in MX
This code may demonstrate the issue better. Any file with 1000 lines will
demonstrate the issue
<pre>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<CFQUERY NAME="fileQ" DATASOURCE="IN5downloads">
SELECT * FROM e:\Test_Export.csv
</CFQUERY>
<body>
<cfoutput>
#fileq.columnList#
</cfoutput>
<CFSET ExportedFile = ''>
<CFSET start = GetTickCount()>
<CFSET OUTFILE = "E:\Test_Export_out.csv">
<CFSET ExportedFile = ExportedFile & OutFile & "<P>">
<CFLOOP QUERY="fileq">
<CFIF #FILEEXISTS(OUTFILE)# is "YES">
<CFSET FileDere = 0>
<CFELSE>
<CFSET FileDere = 1>
</CFIF>
<CFIF FILEDERE EQ 1>
<cffile action="WRITE" file="#OUTFILE#" output="#fileQ.col1#"
addnewline="Yes">
<CFELSE>
<cffile action="APPEND" file="#OUTFILE#" output="#fileQ.col1#"
addnewline="Yes">
</CFIF>
</CFLOOP>
Done
</body>
</html>
</pre>
FattyMatty Guest



Reply With Quote

