WriteFile penalty?

Programming Topics (Computer Chess) and technical aspects as test techniques, book building, program tuning etc

Moderator: Andres Valverde

WriteFile penalty?

Postby Fritz Grau » 01 Oct 2007, 10:27

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?
User avatar
Fritz Grau
 
Posts: 23
Joined: 12 Jul 2006, 13:49
Location: Germany

Re: WriteFile penalty?

Postby Jaap Weidemann » 01 Oct 2007, 17:08

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
Jaap Weidemann
 
Posts: 18
Joined: 11 Aug 2006, 21:34
Location: Stellenbosch, South Africa

Re: WriteFile penalty?

Postby Fritz Grau » 02 Oct 2007, 07:12

Hi Jaap, thank you for the link! As far as I can see, your modification solves my engine's problems with communication to Polyglot.
User avatar
Fritz Grau
 
Posts: 23
Joined: 12 Jul 2006, 13:49
Location: Germany

Re: WriteFile penalty?

Postby YvesLejeail » 03 Oct 2007, 17:05

Hi,
I do not know Delphi language, but does it have the console.writeline feature? Could replace the writefile api thing maybe...
Yves
User avatar
YvesLejeail
 
Posts: 48
Joined: 03 Aug 2005, 17:36
Location: Pertuis, France

Re: WriteFile penalty?

Postby Fritz Grau » 05 Oct 2007, 17:00

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
User avatar
Fritz Grau
 
Posts: 23
Joined: 12 Jul 2006, 13:49
Location: Germany


Return to Programming and Technical Discussions

Who is online

Users browsing this forum: No registered users and 28 guests