Mailboxes to bitboards transition

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
hgm
Posts: 28353
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Mailboxes to bitboards transition

Post by hgm »

You must have had an extremely inefficient mailbox implementation, as normally mailbox and bitboard are about equally fast, within a few percent. It is hard to belive this had anything to do with the board representation at all.
User avatar
emadsen
Posts: 440
Joined: Thu Apr 26, 2012 1:51 am
Location: Oak Park, IL, USA
Full name: Erik Madsen

Re: Mailboxes to bitboards transition

Post by emadsen »

Chessnut1071 wrote: Tue Jan 04, 2022 6:39 am Just finished my bitboard engine although it's the first draft and not quite optimum yet. My integer application of mailbox averaged 2.94 seconds per game solution. The bitboard averaged .045 seconds, or, over 65wx faster on the same solutions. UNBELIEVABLE.
Glad to hear it. 65x is a great gain. You'll never see another speedup like that again. Probably due to more than just switching from mailbox to bitboards, as HGM suggests. You probably had an inefficient mailbox implementation and you may have improved other areas of the code too. Anyhow, glad to hear you got a significant speedup.
Erik Madsen | My C# chess engine: https://www.madchess.net
Chessnut1071
Posts: 313
Joined: Tue Aug 03, 2021 2:41 pm
Full name: Bill Beame

Re: Mailboxes to bitboards transition

Post by Chessnut1071 »

emadsen wrote: Tue Jan 04, 2022 9:26 pm
Chessnut1071 wrote: Tue Jan 04, 2022 6:39 am Just finished my bitboard engine although it's the first draft and not quite optimum yet. My integer application of mailbox averaged 2.94 seconds per game solution. The bitboard averaged .045 seconds, or, over 65wx faster on the same solutions. UNBELIEVABLE.
Glad to hear it. 65x is a great gain. You'll never see another speedup like that again. Probably due to more than just switching from mailbox to bitboards, as HGM suggests. You probably had an inefficient mailbox implementation and you may have improved other areas of the code too. Anyhow, glad to hear you got a significant speedup.
Hi Erik

I know this is going to sound insane, but, on my deep ply solutions where I use the bitboard sort my speed difference is now 447.3795 x faster than by old engine. On 40 mate solutions my old engine takes 60.1020339 seconds vs. 0.0136395027 for the bit board engine. I can't understand the speed difference from my old engine algorithm alone.

My old engine was programmed in C# on Net 4.7.2. The bitboard engine was programmed in C# Net 6.0 using WPF. Also, I used some of my old mailbox arrays for the non-sliding pieces and got a significant increase in speed, about 15%. That may be due to the fact that my non-sliding pieces were not programmed efficiently in my bitboard code. My old engine used to sort an average of 40 legal moves with 12 int64 record fields and 1 double precision sort field. My bitboard engine used your suggestion where all the evaluation metrics were put in a single 64-bit variable by most significant contributor at the higher bit locations. I'm using a basic Shell sort. That probably got me the 10x speed increase.

I'm wondering how much going to Net 6.0 and the WPF impacted the speed.

Thx again for your advice.