Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor restart_backoff_counter
  • Loading branch information
efimov-mikhail committed Nov 19, 2025
commit e17b195eadfdddc39e89233ae7cfdda4e5932c05
12 changes: 5 additions & 7 deletions Include/internal/pycore_backoff.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,11 @@ static inline _Py_BackoffCounter
restart_backoff_counter(_Py_BackoffCounter counter)
{
assert(!is_unreachable_backoff_counter(counter));
int backoff = counter.value_and_backoff & BACKOFF_MASK;
if (backoff < MAX_BACKOFF) {
return make_backoff_counter((1 << (2 * backoff + 3)) - 1, backoff + 1);
}
else {
return make_backoff_counter((1 << (2 * MAX_BACKOFF + 1)) - 1, MAX_BACKOFF);
}
uint16_t backoff = counter.value_and_backoff & BACKOFF_MASK;
assert(backoff <= MAX_BACKOFF);
Comment thread
sergey-miryanov marked this conversation as resolved.
backoff = (backoff == MAX_BACKOFF) ? backoff : backoff + 1;
uint16_t value = (1 << (2 * backoff + 1)) - 1;
return make_backoff_counter(value, backoff);
}

static inline _Py_BackoffCounter
Expand Down