4 ms·
I actually think this would be a very good interview question for someone who would be working on performance critical C++ software (maybe not for an entry-leve
by Sean1708 9y ago
I actually think this would be a very good interview question for someone who would be working on performance critical C++ software (maybe not for an entry-level position though), branch-prediction is something that anyone working in that domain should understand at least the basics of and it could quite easily open up the conversation to other hardware or optimisation topics.
- samfisher83 9y agoYou learn branch prediction in most CS, CE or EE programs.
- tayo42 9y agoWhat kind of class would include that in their curriculum?
- pvarangot 9y agoIt's usually a topic on the first computer architecture class. It's a mid-of-the-book topic on most computer organization books, the classics like Hennesy Patterson or Tanenbaum have substancial portions dedicated to it. Both are books for a first course on computer architecture and design. It's very important to understand it so that you can understand why sometimes pipelining is difficult or impossible.
- samfisher83 9y agoPipelining is done on basically every processor . It is like the laundry example you are not going to wait for dryer to finish before you load the washer. As soon as the clothes are done in the washer you will move them to the dryer and load the washer.
- pvarangot 9y agoYeah if you have branch prediction you can suddenly realize you put dirty clothes in the drier together with clean ones.
- xxpor 9y agoWe learned about in Computer Architecture (EECS 314). We used the textbook "Computer Organization and Design" by David A Patterson and John L Hennessy. Branch Prediction comes up on page 341. I have it sitting on my desk here at work because it's such a useful book.
- mediumdeviation 9y agoOur school introduced it in a year 2 computer organization course that was required for all CS majors. It went into how the processor converts assembly into instructions for the ALU, instruction pipelining, branch prediction (though only qualitatively), and the instruction and data cache, amongst other things.
- ryandrake 9y agoReally, I was going to say this is a good weed-out question for an entry-level position. Topics like pipelining, branch prediction and cache locality were covered in 2nd year computer architecture classes when I went to undergrad. Aren't they teaching this stuff anymore?
- Sohcahtoa82 9y agoIn my school, we were taught about them, sure, but not in great detail. We certainly weren't taught how to detect code that has bad branch prediction behavior or how to write code that prevents branch mispredictions. I don't think we even covered cache locality. I disagree on the original SO question as being a good weed-out question for an entry level position. This is a code optimization that I certainly wouldn't expect a newbie to know.
- squeaky-clean 9y agoYeah but if you don't use that knowledge for 10 years, you forget it. You wouldn't ask a web developer for the dates of the French Revolution in order to prove that they graduated high school.
- ryandrake 9y agoI'm not sure what kind of developer works for 10 years and doesn't use knowledge of how microprocessors work. Is their code being executed by something other than a microprocessor? On the other hand, maybe this is why my E-mail client has a 300MB memory footprint and my browser pegs the CPU when simply opening a web page.
- scrollaway 9y ago> On the other hand, maybe this is why my E-mail client has a 300MB memory footprint and my browser pegs the CPU when simply opening a web page. It sounds a lot more like you don't fully understand what the causes behind these things are and you're ready to arrogantly blame it on developers who dare use javascript without microoptimizing everything. Your email client has a 300MB memory footprint most likely because of its dependencies and the appropriate amount of work invested into it. If it's a commercial product, the company probably doesn't care enough to spend decades optimizing every single layer of the stack down to the compiled assembly just to sell you something for twenty bucks. If it's an open source product, the devs behind it definitely don't have time to do that but OTOH you're welcome to apply your superior knowledge and show everyone how it's done.