-
Notifications
You must be signed in to change notification settings - Fork 2.7k
always have counterMoves associated #1021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
simplifies away all associated checks, leading to a ~0.5% speedup. The code now explicitly checks if moves are OK, rather than using nullptr checks. Verified for no regression: LLR: 2.96 (-2.94,2.94) [-3.00,1.00] Total: 32218 W: 5762 L: 5660 D: 20796 No functional change.
|
The (better) alternative to #1019 |
|
Looks nice! Not sure if the |
|
Here is a version without the cm_ok, fm_ok and fm2_ok variables: I introduced an ===================== Total time (ms) : 149778 Total time (ms) : 150808 ==> testedpatch is 0.7% faster than master Speed test done using this script: |
|
@snicolet thanks! I had is_ok calls in the first implementation, but introduced the variables after a benchmark, suggesting that was faster... however, maybe that benchmark was not very accurate. Do you want me to merge in your changes ? |
|
@vondele You do as you want, it is your code :-) |
|
@snicolet but your changes ;-) I'll have a look later, and a more careful benchmark |
|
@snicolet, in my renewed testing, the is_ok() calls slow down by about 0.3-0.4% , which is consistent with what I had earlier. I'll thus leave the pull request as is, unless there is consensus that having the is_ok() calls should be considered a useful simplification (opinions welcome). For reference, I use the following script for benchmarking, which tries to use a robust estimate of performance: #!/bin/bash
# test performance of stockfish.1 and stockfish.2 binaries.
# number of tests:
ntests=100
printf "Running $ntests tests: "
# remove so we don't mix in data that could be stale
rm -f out.1 out.2
for i in `seq 1 $ntests`
do
printf "%d " $i
# run alternating but simultaneously on 2 cores
for j in $((1+i%2)) $((2-i%2))
do
./stockfish.$j bench 2>&1 | grep 'Nodes/second' | awk '{print $NF}' >> out.$j &
# except on small machines we want one core idle
wait
done
wait
done
printf ".\nDone.\n"
# analysis, run afterwards to not influence the benchmarking
for i in `seq $(((9+ntests)/10)) $(((9+ntests)/10)) $ntests`
do
# use ranking to robustly estimate the speed, avoids outliers.
# 1/3 Rank is near the maximum of the distribution, which is non-Gaussian.
n33=$(((i+2)/3))
v1=`head -n $i out.1 | sort -rn | head -n $n33 | tail -n1`
v2=`head -n $i out.2 | sort -rn | head -n $n33 | tail -n1`
echo "$v1 $v2 $i $ntests"
echo "$v1 $v2 $i $ntests" | awk '{printf("%6d / %6d : current speedup estimate variant 2 (%d ms) vs. variant 1 (%d ms): %8.3f \n",$3,$4,$2,$1,200*($2-$1)/($1+$2))}'
done
|
another ~0.5% speedup. No functional change.
|
Stefan made the acute remark in the comments of the following test that when we use So you should probably use Concerning code style, I would also add some spaces in the for loop, as usual: And maybe a blank line after line 749 ? :-) |
as made by snicolet and locutus2 No functional change.
|
@snicolet thanks for the useful review. All included in the last commit. |
|
@vondele: I try to get this reviewed in the next couple of days... |
simplifies away all associated checks, leading to a ~0.5% speedup.
The code now explicitly checks if moves are OK, rather than using nullptr checks.
Verified for no regression:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 32218 W: 5762 L: 5660 D: 20796
No functional change.