GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Change backoff counter to have larger range and backoff more quickly. · Issue #141498 · python/cpython

Change backoff counter to have larger range and backoff more quickly. #141498

New issue
Copy link
New issue
Copy link
Closed
Closed
Change backoff counter to have larger range and backoff more quickly.#141498
Copy link
Assignees
markshannon
Labels
3.15bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetopic-JIT

Description

@markshannon
markshannon
opened on Nov 13, 2025
Issue body actions

The backoff counter, _Py_BackoffCounter, supports exponential backoff and a value up to 4095.
Backoff is exponential in powers 2.
There are two issues with this:

  • It is a bit slow to backoff: specialization and JIT optimizer failures are rarely transient, so we are wasting effort with backoffs like 2, 4, 8,...
  • It has a relatively low limit of 4095 forcing re-specialization/trace recording every 4095 iteration at most.

The fix is simple, increase the power from 2 to 4. This means we only need 3 bits for the backoff and we get a higher maximum of 8191.
We can also use a lookup table, to ensure that the number of iteration until the next specialization/jit is a prime number

Backoff Value Iterations (value + 1)
0 1 2
1 6 7
6 8190 8191
7 UNREACHABLE_BACKOFF

Linked PRs

  • gh-141498: Change backoff counter to use powers of 4 instead of powers of 2 #141589
  • gh-141498: Change backoff counter to use prime numbers instead of powers of 2 #141591
Reacted by Mikhail Efimov
Reacted by stonebig and Sacul

Activity

  1. markshannon
    added
    performancePerformance or resource usagePerformance or resource usage
    topic-JIT
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    3.15bugs and security fixesbugs and security fixes
    on Nov 13, 2025
  2. markshannon
    self-assigned this
    on Nov 13, 2025
  3. efimov-mikhail commented on Nov 15, 2025

    @efimov-mikhail
    efimov-mikhail
    on Nov 15, 2025
    Member
    More actions

    I'd like to work on this, if you're not against it, @markshannon.

  4. efimov-mikhail commented on Nov 15, 2025

    @efimov-mikhail
    efimov-mikhail
    on Nov 15, 2025
    Member
    More actions

    I've created a PR with minimal fix: 12 + 4 bits -> 13 + 3 bits, value = 2**backoff - 1 -> value = 2**(2*backoff+1) - 1.
    I can add using prime numbers to the same PR, if we want to.

    CC @Fidget-Spinner

  5. markshannon commented on Nov 19, 2025

    @markshannon
    markshannon
    on Nov 19, 2025
    MemberAuthor
    More actions

    I'd like to work on this, if you're not against it, @markshannon.

    I did some work on it, but I'm happy for you to do it. It looks like you already are 🙂

    Reacted by Mikhail Efimov and Savannah Ostrowski
  6. markshannon
    added a commit that references this issue on Nov 21, 2025

    gh-141498: Change backoff counter to use prime numbers instead of pow…

    a3b78a3
  7. markshannon
    closed this as completedon Nov 21, 2025
  8. StanFromIreland
    added a commit that references this issue on Dec 6, 2025

    pythongh-141498: Change backoff counter to use prime numbers instead …

    0fcedd2
  9. ashm-dev
    added a commit that references this issue on Dec 8, 2025

    pythongh-141498: Change backoff counter to use prime numbers instead …

    6387a5e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @markshannon
    markshannon

Labels

3.15bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetopic-JIT

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.