How to speed up my engine

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Henk
Posts: 5833
Joined: Mon May 27, 2013 8:31 am

Re: How to speed up my engine

Post by Henk » Tue May 17, 2016 6:01 pm

I prefer hundred bugs extra in my code then having my code polluted with all kinds of annoying asserts and tests that hardly ever catch any errors.

[Wait a minute you are programming in C++ and not C#. Maybe in that case I would add asserts too for C++ code is unsafe]

jdart
Posts: 3842
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

Re: How to speed up my engine

Post by jdart » Thu May 19, 2016 3:11 am

Asserts help because they can catch something wrong before you crash .. sometimes you do something wrong (like execute an invalid move) and hundreds or thousands of machine instructions later, you crash.

But if you don't like asserts .. at least check out the new flags in GCC 5.0, for example -fsanitize=bounds.

--Jon

Henk
Posts: 5833
Joined: Mon May 27, 2013 8:31 am

Re: How to speed up my engine

Post by Henk » Thu May 19, 2016 2:12 pm

If one tries to add complete post conditions you really make it unnecessarily complex.

bob
Posts: 20642
Joined: Mon Feb 27, 2006 6:30 pm
Location: Birmingham, AL

Re: How to speed up my engine

Post by bob » Thu May 19, 2016 4:33 pm

Henk wrote:If one tries to add complete post conditions you really make it unnecessarily complex.
Debugging is not easy nor fast. The more you get the compiler to help, the less you have to figure out mentally.

X-rays, CT scans and MRI's are extremely complex processes. Should we get rid of those and do it the direct way (exploratory surgery) instead?

wgarvin
Posts: 838
Joined: Thu Jul 05, 2007 3:03 pm
Location: British Columbia, Canada

Re: How to speed up my engine

Post by wgarvin » Fri May 20, 2016 2:13 am

Asserts are a way for programmers to check their assumptions at runtime.

If you thought the program would be in a certain state at that point and its not in that state, you want to find out about that sooner rather than later.

As John Carmack once wrote:
Most bugs are a result of the execution state not being exactly what you think it is.
Asserts are of course NOT for error handling. (Thats why you can disable them in a Release build for better performance: if the program is correct the asserts should never fire anyway). 8-)

[Edit: Figuring out exactly which asserts are worth putting in, is a bit of an art. At least with practice you get better at it.]

lauriet
Posts: 162
Joined: Sun Nov 03, 2013 8:32 am
Contact:

Re: How to speed up my engine

Post by lauriet » Fri May 20, 2016 6:53 am

bob wrote:
Henk wrote:If one tries to add complete post conditions you really make it unnecessarily complex.
Debugging is not easy nor fast. The more you get the compiler to help, the less you have to figure out mentally.

X-rays, CT scans and MRI's are extremely complex processes. Should we get rid of those and do it the direct way (exploratory surgery) instead?

"Bloody Hell...Damn Straight" Thats Australian for
"Gee Wiz, you sure are right"

Of all the programming I have done, debugging chess software is the hardest. Normally I can use the built in debugger and find the error pretty quickly. But with search the debugger seems to get confused with all the nested/recursive calls and never displays the variables properley. How do you find a bug that only shows up at node 10,265,356 ????

Laurie.

User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 6:43 pm

Re: How to speed up my engine

Post by sje » Fri May 20, 2016 11:35 am

lauriet wrote:But with search the debugger seems to get confused with all the nested/recursive calls and never displays the variables properley. How do you find a bug that only shows up at node 10,265,356 ????
Use a non-recursive, finite state machine search.

User avatar
Werner Taelemans
Posts: 103
Joined: Mon Feb 03, 2014 10:57 am
Location: Belgium
Contact:

Re: How to speed up my engine

Post by Werner Taelemans » Fri May 20, 2016 6:25 pm

lauriet wrote:How do you find a bug that only shows up at node 10,265,356 ????
Laurie.
Add a counter in your make_move(). Increment this counter each time you do a move (and don't decrement in unmake_move() )
When you find a bug, print this counter, and if it says 10,265,356, start logging from 10,265,000.
There's no need to log millions of nodes.

User avatar
Rebel
Posts: 4789
Joined: Thu Aug 18, 2011 10:04 am

Re: How to speed up my engine

Post by Rebel » Fri May 20, 2016 7:13 pm

Never used assert, neither a debugger, well maybe 1-2 times.

My philosophy was (still is) type small changes and test it immediately, if needed displaying the contents of variables with printf. Small steps, few bugs.

Post Reply