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

GH-104584: Optimizer API by markshannon · Pull Request #105100 · python/cpython · GitHub

/ cpython Public

GH-104584: Optimizer API - #105100

Merged
markshannon merged 18 commits into
python:mainfrom
faster-cpython:optimizer-api
Jun 2, 2023
Merged

GH-104584: Optimizer API#105100
markshannon merged 18 commits into
python:mainfrom
faster-cpython:optimizer-api

Conversation

markshannon commented May 30, 2023
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

Only supports back edges. Adding hooks for resumption points (the RESUME instruction) is for a later PR.

Performance for an earlier version was mostly noise.

In theory we could turn off the check by using adaptive bytecode, but as we will want an always-on optimizer for tier 2, there seems little advantage to doing so.

Fidget-Spinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks good in general. Probably needs a test with buildbots though.

Comment thread Python/optimizer.c Outdated
Comment thread Python/optimizer.c Outdated
Comment thread Python/optimizer.c Outdated
Comment thread Python/optimizer.c Outdated
Comment thread Python/optimizer.c Outdated
Comment thread Python/optimizer.c Outdated
Comment thread Python/optimizer.c Outdated

brandtbucher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Cool! Just a small flurry of questions, comments, and nits:

Comment thread Lib/opcode.py
Comment thread Include/cpython/code.h Outdated
Comment thread Include/cpython/code.h Outdated
Comment thread Python/ceval_macros.h
Comment thread Python/bytecodes.c
Comment thread Python/optimizer.c
Comment thread Python/optimizer.c Outdated
Comment thread Python/optimizer.c Outdated
Comment thread Python/optimizer.c Outdated
Comment thread Python/optimizer.c Outdated
Comment thread Include/internal/pycore_interp.h Outdated
Comment thread Python/bytecodes.c
Comment thread Python/optimizer.c
Comment thread Python/optimizer.c Outdated
Comment thread Python/bytecodes.c
Comment on lines +2121 to +2129
here[1].cache += (1 << OPTIMIZER_BITS_IN_COUNTER);
if (here[1].cache > tstate->interp->optimizer_backedge_threshold) {
OBJECT_STAT_INC(optimization_attempts);
frame = _PyOptimizer_BackEdge(frame, here, next_instr, stack_pointer);
if (frame == NULL) {
frame = cframe.current_frame;
goto error;
}
here[1].cache &= ((1 << OPTIMIZER_BITS_IN_COUNTER) -1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm a bit confused about how an optimizer would actually make use of these four bits. The optimizer only gets invoked when its threshold is met, and when the optimizer is invoked, it is required to return an executor (returning NULL signals an exception). The executor will generally be per-hotspot, and can have as much custom state in it as the optimizer wants.

I guess the use case might be that sometimes an optimizer will choose to set a shared no-op executor for some reason (so if it's shared, it can't store per-hotspot state in it), but still want to store some per-hotspot state?

Comment thread Python/optimizer.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants


Back | FazBrowse Home | New Git URL