FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Factor out tracing and optimization heuristics into a single "policy" object. · Issue #141504 · python/cpython · GitHub

Repository navigation

Factor out tracing and optimization heuristics into a single "policy" object. #141504

Closed

Description

The SAI, tracer and optimizer all contain a number of heuristics about when to optimize, how to link the optimized code and when to backoff, etc.

Almost all of these heuristics are just numbers.
We should group them together into a single "policy" object, improving consistency and enabling experimentation.

Linked PRs

Activity

  1. Fidget-Spinner commented on Nov 13, 2025

    Member

    This sounds rather promising. It would also enable per-system configurations, like pypy which would be great.

  2. Krishna-web-hub commented on Dec 8, 2025

    Contributor

    Hi @markshannon , @Fidget-Spinner,

    As we can see the SAI and tracer and optimizers all contains a lot of numbers which make it difficult to do any changes. And i appreciate the idea to make common policy for them such that we can pinpoint the exact area where the error is produced rather than searching here and there.

    So i came up with an idea of creating a header file policy.h which will be telling what structure and functions are defined or used in the main code and along with the logic of the function will be present inside the policy.c where we will be having the function logic for when to start optimizing the function and also when to stops the function. Then we will be replacing the loop inside value with the function which return Boolean value as the and according to that the loop will stops or checking is done.

    But the issue is that after that we will have to replace many function to increase the speed and make it easier to handle any changes or disturbances which is going to take long time but in other hand it is like a updated version of 3.15 which is a little bit better than it.
    So i suggest that we can work on it by breaking into small segments so that will also be better and easier for us to approach this idea.

    If you like this idea let me know. I will generate a pr for it.

  3. Fidget-Spinner commented on Dec 8, 2025

    Member

    @Krishna-web-hub Sorry I don't think you're on the right track. Please don't take this issue.

  4. Krishna-web-hub commented on Dec 8, 2025

    Contributor

    Thanks for the feedback, @Fidget-Spinner. I'll read through the original proposal again and see if I can come up with an approach that better fits the 'single policy object' goal.

  5. Fidget-Spinner commented on Dec 8, 2025

    Member

    @Krishna-web-hub I don't think this is a good issue for beginners. So you might want to try another issue

  6. Fidget-Spinner commented on Jan 2, 2026

    Member

    @corona10 and I are working on it.

  7. added 2 commits that reference this issue on Jan 3, 2026
  8. markshannon commented on Jan 5, 2026

    MemberAuthor

    Apparently I wasn't clear as to what I wanted.

    We want to be able to allow users to choose between policies at runtime, and to simplify creation of new policies and do other experiments with thresholds.

    However, there are a number of invariants that must hold: certain thresholds should be higher than others, we shouldn't allow the JIT without specialization, etc.
    Rather than expect users to know all these hazards, we should provide a fixed set of "policies" to choose from:

    • Default
    • JIT stress: very low thresholds for testing, specifically fuzzing
    • JIT on/off
    • Specialization off (useful when changing the bytecode compiler)
    • ...

    To do this we should group all the various thresholds and optimization flags, for both JIT and interpreter, into a single opt_config struct, one per interpreter.

  9. added 4 commits that reference this issue on Jan 10, 2026
  10. Fidget-Spinner commented on Jan 17, 2026

    Member

    @corona10 would you like to take on moving PYTHON_UOPS_OPTIMIZE as well? We should move it from optimizer.c to the policy object + env var like you did in your other PRs.

  11. corona10 commented on Jan 17, 2026

    Member

    Sure!

  12. added a commit that references this issue on Jan 20, 2026
  13. added a commit that references this issue on Jan 20, 2026
  14. added 3 commits that reference this issue on Feb 15, 2026
  15. Fidget-Spinner commented on Apr 15, 2026

    Member

    This looks done. can we close it?

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

Metadata

Metadata

Labels

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

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL