Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-118095: Add dynamic exit support and FOR_ITER_GEN support to tier 2 #118279

Merged
merged 3 commits into from
Apr 26, 2024

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Apr 25, 2024

assert(next_instr - this_instr + oparg <= UINT16_MAX);
frame->return_offset = (uint16_t)(next_instr - this_instr + oparg);
DISPATCH_INLINED(gen_frame);
frame->return_offset = (uint16_t)(2 + oparg);
Copy link
Member

Choose a reason for hiding this comment

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

What does 2 stand for? Can you add a comment?

Comment on lines 3174 to 3176
// The 'unused' output effect represents the return value
// (which will be pushed when the frame returns).
// It is needed so CALL_PY_EXACT_ARGS matches its family.
Copy link
Member

Choose a reason for hiding this comment

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

This comment is outdated -- I suggest just deleting it.

@@ -87,6 +87,7 @@ _JIT_ENTRY(_PyInterpreterFrame *frame, PyObject **stack_pointer, PyThreadState *
PATCH_VALUE(_PyExecutorObject *, current_executor, _JIT_EXECUTOR)
int oparg;
int uopcode = _JIT_OPCODE;
_Py_CODEUNIT *next_instr;
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to know what @brandtbucher thinks of this.

Comment on lines 4208 to 4209
if (!backoff_counter_triggers(exit->temperature)) {
GOTO_TIER_ONE(target);
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't advance the temperature. From _SIDE_EXIT, it looks like the correct idiom is

            _Py_BackoffCounter temperature = exit->temperature;
            if (!backoff_counter_triggers(temperature)) {
                exit->temperature = advance_backoff_counter(temperature);
                GOTO_TIER_ONE(target);
            }

@@ -4222,6 +4258,7 @@ dummy_func(
GOTO_UNWIND();
}


Copy link
Member

Choose a reason for hiding this comment

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

Stray blank line?

@markshannon
Copy link
Member Author

The usual four failures.

@markshannon markshannon merged commit 3e06c7f into python:main Apr 26, 2024
56 of 60 checks passed
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 RHEL7 LTO 3.x has failed when building commit 3e06c7f.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/507/builds/7303) and take a look at the build logs.
  4. Check if the failure is related to this commit (3e06c7f) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/507/builds/7303

Failed tests:

  • test_capi

Summary of the results of the build (if available):

==

Click to see traceback logs
remote: Enumerating objects: 43, done.        
remote: Counting objects:   2% (1/43)        
remote: Counting objects:   4% (2/43)        
remote: Counting objects:   6% (3/43)        
remote: Counting objects:   9% (4/43)        
remote: Counting objects:  11% (5/43)        
remote: Counting objects:  13% (6/43)        
remote: Counting objects:  16% (7/43)        
remote: Counting objects:  18% (8/43)        
remote: Counting objects:  20% (9/43)        
remote: Counting objects:  23% (10/43)        
remote: Counting objects:  25% (11/43)        
remote: Counting objects:  27% (12/43)        
remote: Counting objects:  30% (13/43)        
remote: Counting objects:  32% (14/43)        
remote: Counting objects:  34% (15/43)        
remote: Counting objects:  37% (16/43)        
remote: Counting objects:  39% (17/43)        
remote: Counting objects:  41% (18/43)        
remote: Counting objects:  44% (19/43)        
remote: Counting objects:  46% (20/43)        
remote: Counting objects:  48% (21/43)        
remote: Counting objects:  51% (22/43)        
remote: Counting objects:  53% (23/43)        
remote: Counting objects:  55% (24/43)        
remote: Counting objects:  58% (25/43)        
remote: Counting objects:  60% (26/43)        
remote: Counting objects:  62% (27/43)        
remote: Counting objects:  65% (28/43)        
remote: Counting objects:  67% (29/43)        
remote: Counting objects:  69% (30/43)        
remote: Counting objects:  72% (31/43)        
remote: Counting objects:  74% (32/43)        
remote: Counting objects:  76% (33/43)        
remote: Counting objects:  79% (34/43)        
remote: Counting objects:  81% (35/43)        
remote: Counting objects:  83% (36/43)        
remote: Counting objects:  86% (37/43)        
remote: Counting objects:  88% (38/43)        
remote: Counting objects:  90% (39/43)        
remote: Counting objects:  93% (40/43)        
remote: Counting objects:  95% (41/43)        
remote: Counting objects:  97% (42/43)        
remote: Counting objects: 100% (43/43)        
remote: Counting objects: 100% (43/43), done.        
remote: Compressing objects:   5% (1/17)        
remote: Compressing objects:  11% (2/17)        
remote: Compressing objects:  17% (3/17)        
remote: Compressing objects:  23% (4/17)        
remote: Compressing objects:  29% (5/17)        
remote: Compressing objects:  35% (6/17)        
remote: Compressing objects:  41% (7/17)        
remote: Compressing objects:  47% (8/17)        
remote: Compressing objects:  52% (9/17)        
remote: Compressing objects:  58% (10/17)        
remote: Compressing objects:  64% (11/17)        
remote: Compressing objects:  70% (12/17)        
remote: Compressing objects:  76% (13/17)        
remote: Compressing objects:  82% (14/17)        
remote: Compressing objects:  88% (15/17)        
remote: Compressing objects:  94% (16/17)        
remote: Compressing objects: 100% (17/17)        
remote: Compressing objects: 100% (17/17), done.        
remote: Total 22 (delta 21), reused 6 (delta 5), pack-reused 0        
From https://github.com/python/cpython
 * branch            main       -> FETCH_HEAD
Note: checking out '3e06c7f719b99cc7f5e8889319cff4980e41d3e8'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at 3e06c7f... GH-118095: Add dynamic exit support and FOR_ITER_GEN support to tier 2 (GH-118279)
Switched to and reset branch 'main'

In file included from Python/optimizer_analysis.c:437:
Python/optimizer_cases.c.h: In function ‘optimize_uops’:
Python/optimizer_cases.c.h:1444:23: warning: assignment to ‘_PyInterpreterFrame *’ {aka ‘struct _PyInterpreterFrame *’} from incompatible pointer type ‘_Py_UopsSymbol *’ {aka ‘struct _Py_UopsSymbol *’} [-Wincompatible-pointer-types]
             gen_frame = sym_new_not_null(ctx);
                       ^

make: *** [Makefile:2232: buildbottest] Error 2

@gvanrossum
Copy link
Member

@markshannon I now get this warning:

In file included from Python/optimizer_analysis.c:439:
Python/optimizer_cases.c.h:1444:23: warning: incompatible pointer types assigning to '_PyInterpreterFrame *' (aka 'struct _PyInterpreterFrame *') from '_Py_UopsSymbol *' (aka 'struct _Py_UopsSymbol *') [-Wincompatible-pointer-types]
            gen_frame = sym_new_not_null(ctx);
                      ^ ~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

That's in here:

        case _FOR_ITER_GEN_FRAME: {
            _PyInterpreterFrame *gen_frame;
            gen_frame = sym_new_not_null(ctx);
            if (gen_frame == NULL) goto out_of_space;
            stack_pointer[0] = (_Py_UopsSymbol *)gen_frame;
            stack_pointer += 1;
            break;
        }

Apparently generated by the generator using the default code generation strategy. We may need to add a dummy case for _FOR_ITER_GEN_FRAME in optimizer_bytecodes.c to avoid this cast.

(@Fidget-Spinner Or is there another way to fix this?)

@Fidget-Spinner
Copy link
Member

The optimizer bytecodes shouldnt even use the cast. I should fix that because ifs interfering with tagged ptrs too

@Fidget-Spinner
Copy link
Member

For now, we can just override it I think as a hotfix.

@markshannon markshannon deleted the tier-2-for-iter-gen branch August 6, 2024 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants