Page 1 of 1

LUA Slow File Append

Posted: 06 Dec 2011 13:09
by tatewise
The FH LUA file system runs very slowly sometimes.
In some situations it appears to have frozen FH in a 'hung' state.
The following LUA Plugin exhibits the problem and takes nearly a minute to complete:

for i=1,500 do
     file, err = io.open('Test.log','a')
     if file == nil then error(err) end
     file:write('Data:0,1,'2'n')
     file:close()
end

The following elements must be present in the written line:
The word Data: at start or end of line
Some commas , separating other data
Pair of quotes ' or '

If a line such as file:write('Data=0 1 (2)n') is used instead, it completes within a second or two.

The problem appears to be not so much what is being written, but that the above key elements exist in lines in the file being appended.
It afflicts Windows 7 and Vista but not my copy of XP.

The problem came to light because my LUA Plugin was writing a log file using the word Data: and contained commas and quotes.
As the file grew large the LUA Plugin took several minutes to complete the log, and appeared to have 'hung'.
If the word Data: was changed to Data= it completed in a second or two.

ID:5616

LUA Slow File Append

Posted: 06 Dec 2011 15:41
by Jane
I have just pasted your code in to FH and it ran in under a second even when in the debugger. system : Win 7 x64

Is it possible another program on your system (a backup program or antivirus perhaps?) is conflicting.

LUA Slow File Append

Posted: 06 Dec 2011 16:11
by tatewise
I have tried various things such as switching off Indexed Search to no avail.

It appears to be caused by Microsoft Security Essentials on its Settings tab Real-time protection options.
If I untick Monitor file and program activity on your computer the problem vanishes.

MSE is on Windows 7 and Vista but not XP.

Strange that such a specific combination of characters upset it.