Mostly used when discussing computer
s, branch prediction is the ability to simulate (through ad-hoc
kery of varying degrees of sophistication) the result of an imminent conditional branch in the workflow
. In stupid systems (most computers belong in this category), one path is chosen randomly and the work resulting from the branch condition is started. In the event of a lucky - if educated - guess, some of the work initiated due to the outcome of the branch is already done. If not, nothing is lost, since the time from 'program reaches branch' to ' program chooses which branch to follow' would be spent idling
In a multitasking environment, branch prediction doesn't provide much of a performance boost, since other processes might use the spare clock cycles instead of risking them on meaningless work whilst other processes are ready to run. Therefore, branching is usually reserved for slop.