diff --git a/Python/optimizer.c b/Python/optimizer.c index 9198e410627dd4e..1edd392268250ef 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -642,14 +642,15 @@ translate_bytecode_to_trace( int bitcount = _Py_popcount32(counter); int jump_likely = bitcount > 8; /* If bitcount is 8 (half the jumps were taken), adjust confidence by 50%. - If it's 16 or 0 (all or none were taken), adjust by 10% - (since the future is still somewhat uncertain). + If it's 16 or 0 (all or none were taken), adjust by ~6% + (since the future is still somewhat uncertain - see Laplace's + rule of succession, used here with 16 observations). For values in between, adjust proportionally. */ if (jump_likely) { - confidence = confidence * (bitcount + 2) / 20; + confidence = confidence * (bitcount + 1) / 18; } else { - confidence = confidence * (18 - bitcount) / 20; + confidence = confidence * (17 - bitcount) / 18; } uint32_t uopcode = BRANCH_TO_GUARD[opcode - POP_JUMP_IF_FALSE][jump_likely]; DPRINTF(2, "%d: %s(%d): counter=%04x, bitcount=%d, likely=%d, confidence=%d, uopcode=%s\n",