You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Branch confidence decay in Tier 2 translator #112320
When we translate a branch instruction (e.g. POP_JUMP_IF_TRUE), Tier 1 has a 16-bit shift register tracking how often we branched in the past 16 times this instruction was reached. During Tier 2 translation, if the bit count indicates that we've taken the branch more often than not, we continue the trace at the branch destination; otherwise, we continue following the branch instruction.
What we should also do in the translator have a variable (for the entire trace) indicating how likely we are still "on trace". This "confidence factor" starts off at 100%. If we translate a branch that is taken X% of the time, for X >= 50%, we should multiply the confidence by X%. If the confidence ends too low (say, below 33%) we should end the trace at this point, generating an _EXIT_TRACE uop.
UPDATE: Ideally we should also adjust the confidence each time we generate a guard. But what factor should we use there? Most guards fail rarely. I propose to punt on this now; later we can add code to adjust the same variable on deoptimization exits.
Activity
[-]BranchBrahch confidence decay in Tier 2 translator [/-][+]Branch confidence decay in Tier 2 translator [/+]gh-112320: Implement on-trace confidence tracking for branches (#112321)
pythongh-112320: Implement on-trace confidence tracking for branches (p…
hugovk commentedon Mar 15, 2024
Closing because the PR has been merged. Please re-open if there's more needed here.
gvanrossum commentedon Mar 15, 2024
Thanks, and sorry. I usually forget to use the "fixes gh-blahblah" magic phrase. :-(
pythongh-112320: Implement on-trace confidence tracking for branches (p…