Skip to content
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

Chapter 10 #34

Merged
merged 3 commits into from
Dec 1, 2023
Merged

Chapter 10 #34

merged 3 commits into from
Dec 1, 2023

Conversation

aaupov
Copy link
Contributor

@aaupov aaupov commented Nov 24, 2023

Reflow and add some bits about 3 Cs, code layout effects, and perf impact of never taken branches.

@dendibakh
Copy link
Owner

Thanks Amir, I will accept your additions but revert reflow commit. The rest of the book is not formatted as 80 characters per line, so I will not introduce any inconsistency. Maybe later.
Also, I will make some more cosmetic changes as I planned for this section.

@aaupov
Copy link
Contributor Author

aaupov commented Nov 27, 2023

No problem, I was just editing the text offline from cli, hence the reflow.

@dendibakh
Copy link
Owner

I will make my cosmetic changes in a separate commit.

@dendibakh dendibakh merged commit 2e92bfe into dendibakh:main Dec 1, 2023
1 check passed

Perhaps, the only direct way to get rid of branch mispredictions is to get rid of the branch itself. In the two subsequent sections, we will take a look at how branches can be replaced with lookup tables and predication.
\personal{There is a conventional wisdom that never taken branches are transparent to the branch prediction and can't affect performance, and therefore it doesn't make much sense to remove them, at least from prediction perspective. However, contrary to the wisdom, an experiment conducted by BOLT authors demonstrated that replacing never taken branches with equal-sized no-ops in a large code footprint application (Clang binary) leads to approx. 5\% speedup on modern Intel CPUs. So it still pays to try to eliminate all branches.}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aaupov , do you have a link that describes the experiment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maksfb – we don't have any writeup about this, do we?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants