jckarter

everyone already knows i'm a dog

the swift programming language is my fault to some degree. mostly here to see dogs, shitpost, fix old computers, and/or talk about math and weird computer programming things. for effortposts check the #longpost pinned tag. asks are open.


email
mailto:joe@duriansoftware.com
discord
jckarter

Catfish-Man
@Catfish-Man

I greatly enjoyed this article about how to design CPU instruction sets. Lots of interesting perspective that I hadn't properly considered before.

Probably my favorite bit was just a bit of straightforward arithmetic that I could have done but hadn't thought to: branch mispredict rate * (reorder buffer size / typical basic block length)

With a seven-stage dual-issue pipeline, you might have 14 instructions in flight at a time. If you incorrectly predict a branch, half of these will be the wrong ones and will need to be rolled back, making your real throughput only half of your theoretical throughput. Modern high-end cores typically have around 200 in-flight instructions—that is over 28 basic blocks, so a 95% branch predictor accuracy rate gives less than a 24% probability of correctly predicting every branch being executed. Big cores really like anything that can reduce the cost of misprediction penalties.

I knew branch prediction was critical (Dan Luu's article on that is my favorite), but hadn't internalized just how fast the numbers get bad for big out of order cores.


You must log in to comment.

in reply to @Catfish-Man's post:

oh dang, I'm a dingus, but never thought about how a single misprediction results in all the instructions in the pipeline getting rolled back. that's really neat! I'm gonna go read this article