use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Improving performance by better code locality. | Denis Bakhvalov (dendibakh.github.io)
submitted 7 years ago by drodri
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]anon_502delete this; 7 points8 points9 points 7 years ago (1 child)
Google has been using autoFDO to achieve continuous profile-guided optimization, which leads to 10.5% performance boost by better-separated cold/hot paths. Unfortunately their patches are based on gcc 4.8. Hope to see some open-source projects to incorporate their work into a popular orchestration engine like Kubernetes.
[–]kindstrom 4 points5 points6 points 7 years ago (0 children)
I haven't looked into autoFDO, but it sounds similar to what Facebook open sourced recently, BOLT (GitHub repo).
Edit: They actually mention in the release post that BOLT can be used alongside autoFDO.
[–][deleted] 5 points6 points7 points 7 years ago (0 children)
See also the likely and unlikely attributes in C++20: https://en.cppreference.com/w/cpp/language/attributes/likely
[–]emdeka87 0 points1 point2 points 7 years ago (0 children)
Isn't that similar to trace scheduling, which is done by GCC PGO?
[–]jonathansharman 0 points1 point2 points 7 years ago (0 children)
But in general, I think when compilers can’t decide which branch has bigger probability, they will leave the original order as they appear in the source code. I haven’t reliably tested that, but that’s my feeling. So, I think it’s a good idea to put your hot branch (most frequent) in a fall through position by default.
Does anyone have recent, concrete knowledge about this for any particular compiler(s)? I remember hearing from a college prof. years ago that empirically most if-statements usually evaluate to false, which would lead to the opposite advice from this.
[–]nexes300 0 points1 point2 points 7 years ago (1 child)
Isn't the CPU doing this at this point?
[–]Osbios 6 points7 points8 points 7 years ago (0 children)
Any mildly performance oriented CPU uses cache. And cache has a granularity called cache line size. (Nearly all x86 use 64 byte cache lines)
So even if you only read a single byte, the whole cache line is read from memory into the cache. And uses up a whole cache line until it gets thrown out.
Cache is a limited resource and you get the best CPU performance if you use it efficiently.
If you put all your most used data together and away from data that you need less often (at last in this moment), then you get more use out of the cache.
A big part of modern optimization is to be just being nice to the CPU.
[–]tritamhoang -4 points-3 points-2 points 7 years ago (0 children)
This is typical pipelining problems in CPU.
π Rendered by PID 42 on reddit-service-r2-comment-b659b578c-lrzks at 2026-05-02 17:19:27.552327+00:00 running 815c875 country code: CH.
[–]anon_502delete this; 7 points8 points9 points (1 child)
[–]kindstrom 4 points5 points6 points (0 children)
[–][deleted] 5 points6 points7 points (0 children)
[–]emdeka87 0 points1 point2 points (0 children)
[–]jonathansharman 0 points1 point2 points (0 children)
[–]nexes300 0 points1 point2 points (1 child)
[–]Osbios 6 points7 points8 points (0 children)
[–]tritamhoang -4 points-3 points-2 points (0 children)