Page 1 of 1

WriteFile penalty?

PostPosted: 01 Oct 2007, 10:27
by Fritz Grau
My engine (Feuerstein, UCI-protocol, written in Delphi) seems to have some trouble with communication to Arena/Polyglot, resulting in occasional time losses in ponder mode games. Therefore, I removed threading as a possible source of complications and logged every action. Much to my surprise, problems do not occur when my engine reads input but when it writes an output line - although that is done by a simple call to the WinAPI function WriteFile. Incidentally the same method is used the Delfi 5.1 source. Further logging showed that when in ponder mode, the execution of one single WriteFile command (without Overlap structure) usually works instantly, but sometimes requires around 5-10 seconds or even more. This usually happens in ponder mode, and the only special circumstance I could discover was that the problem usually occured when a few write operations were done in quick progression.

Is there some kind of timeout for WriteFile operations under Windows? Has anybody experienced (and solved) a similar problem?

Further questions:
1. How can it be that engines who run fine without pondering and use the same communication methods in ponder mode experience problems in ponder mode games at fast time controls?
2. The problem described above (i.e. the engine hangs for several seconds with 0% CPU load during a WriteFile execution) only happens when communicating with the Arena interface. In communication with the Polyglot interface, WriteFile always work instantly, but the communication Engine <-> Polyglot <-> WinBoard seems to get stuck at similar random intervals, only the reason is hard to investigate because the Polyglot log lacks timestamps. Is there a Polyglot option that would make Polyglot add timestamps to its log file?

Re: WriteFile penalty?

PostPosted: 01 Oct 2007, 17:08
by Jaap Weidemann
Hi Fritz

With PolyGlot the problems seems to be "racing". This can be solved by increasing PolyGlot's priority slightly (by -6 or to "AboveNormal") relative to XBoard (or WinBoard) and the engine. You can find a PolyGlot version with this hack here. If this does not solve your problem please let me know so I can provide you with a log timestamp capable PolyGlot.

Jaap

Re: WriteFile penalty?

PostPosted: 02 Oct 2007, 07:12
by Fritz Grau
Hi Jaap, thank you for the link! As far as I can see, your modification solves my engine's problems with communication to Polyglot.

Re: WriteFile penalty?

PostPosted: 03 Oct 2007, 17:05
by YvesLejeail
Hi,
I do not know Delphi language, but does it have the console.writeline feature? Could replace the writefile api thing maybe...
Yves

Re: WriteFile penalty?

PostPosted: 05 Oct 2007, 17:00
by Fritz Grau
Yves Lejeail wrote:I do not know Delphi language, but does it have the console.writeline feature? Could replace the writefile api thing maybe...


Hi Yves,

thank you for the suggestion. In Delphi, the standard command to write to a line to the console is "WriteLn". I am not sure whether that is the feature you meant: I tried it, but the GUI doesn't seem to receive the result.

Anyhow, since the problem I described only occurs in communication with Arena, and communication with Jaap Weidemann's Polyglot version seems to be rather stable, I am not sure anymore that my engine is responsible for the strange effect in communication with Arena.

Fritz