-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Small cleanups 06 #2628
Small cleanups 06 #2628
Conversation
Starting with an empty PR to collect suggestions for small cleanups. No functional change.
This is not big, but... |
@Vizvezdenec the idea behind is that PvNode is a constexpr.... i.e. known at compile time. cutNode is known only at runtime hence small. Other example are RazorMargin (compile time constant), like most other compile time constants, but we're not 100% consistent e.g. ttHitAverageWindow (should be TtHitAverageWindow). |
I'm just saying that PvNode is the same caliber of bool as rootNode and cutNode - and they are both from lowercase. |
These are faster on my machines, and, to me, they are easier to read/understand. |
I have this refactoring of E: link on top of this branch https://github.com/vondele/Stockfish/compare/smallCleanups06...Lolligerhans:shift?expand=1 If the change is welcomed I can add comments or change formatting. |
Complexity can use clamp. |
For pos.castling_rights(Color c), we can use the correct operator in types.h. |
We don't need to ~pos.checkers() every time. This is a little faster: master...protonspring:ps_sliderattacks3 master nps: 1606695, patch nps: 1634694 |
@protonspring I originally thought having the ~pos.checkers() outside of the loop would be more efficient as well but as @Rocky640 pointed out here(and I verified) |
Personally, I had an easier time if there were |
There's an unnecessary |
Some very minor typos in comments in tbprobe.cpp: master...silversolver1:tbprobe_typos_1 |
@@ -412,11 +412,11 @@ constexpr Rank rank_of(Square s) { | |||
} | |||
|
|||
constexpr Square relative_square(Color c, Square s) { | |||
return Square(s ^ (c * 56)); | |||
return c == WHITE ? s : flip_rank(s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and line 419 changes are actually somewhat slower on my machine. It seems that introducing branching is not a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get bit by this occasionally. Patches test faster on my machine, but others say it's slower. Any ways to counteract that? How are you testing performance?
@protonspring I use Fishbench from https://github.com/zardav/FishBench w/ 40 tests which eliminates/reduces variance from run to run and issues with turbo boost because both master and patch run simultaneously. It is known that sometimes different versions may perform slightly differently on different machines so getting others to verify speed differences is a good thing. |
@protonspring @mstembera |
@Rocky640 I used gcc 8.1, bmi2, & windows. |
@Rocky640 My numbers were on gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0. I don't remember enabling bmi, so it's probably not enabled. |
@mstembera @protonspring next to the setup, the measured speedup/slowdown, and the estimated error for that would be useful as well. |
I personally subscribe to the guideline that when in doubt it's best to avoid branching because branches are usually slower and less deterministic in performance(due to branch prediction issues) than normal instructions. Master is also nicely symmetric for white and black. |
some ideas:
for example, with intellisense on in VSCode, when hovering over a function that's commented without whitespace between the comment and the function definition, you get a nice annotation. some functions like but for functions where there's a space between the comment and the function, it's blank when there could be an annotation. example: when the whitespace is removed, hovering over this shows the comment, which is a lot more useful: |
search.cpp line 837
can now be simplified into
I verified it delivers same bench number (tested with default bench & stockfish.exe bench 16 1 21). |
@pb00068 no need to test. |
@linrock concerning your suggestions.
|
Why do we even need this variable? |
@Vizvezdenec this variable was historically request by zamar #1066 (comment) it makes sense since the same value (minus 1) must be used in Thread::clear otherwise the implementation is incorrect. |
Starting with an empty PR to collect suggestions for small cleanups.
No functional change.