You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@markshannon Do you have any idea what could be going on here? I'm afraid I don't completely understand what the failing test (test_store_attr_with_hint) is doing.
@markshannon I'm not at all sure I have the right fix (#108312 just disables the optimizer for the duration of the one test).
It looks like there's some non-determinism between the specialization of LOAD_ATTR and the optimizer on JUMP_BACKWARD -- if the latter runs first, LOAD_ATTR will never be specialized. But the question is, why would this happen sometimes but not all the time? When looking into it a few days ago in more detail, IIRC I found that 1 out of 1000 runs had this problem, where every other run had the correct specialization.) Maybe some counter does not get deterministically reset by .replace()?
I think we do need to disable the executor-based optimizer for these tests. I observed that this loop in assert_specialized
for _ in range(self.WARMUPS):
read(items)
gets translated into a superblock, tracing into the read() function:
def read(items):
for item in items:
item.a = None
before read() has had a chance to specialize its STORE_ATTR (which is currently a viable Tier 2 opcode). So then the subsequent assert_specialized() call fails.
Note that the tracing into read() stops when it encounters the JUMP_BACKWARD of the loop in read(); but it has already executed the unspecialized STORE_ATTR at that point, and it keeps doing so (during the warmup phase), until that JUMP_BACKWARD itself gets translated to Tier 2.
FWIW I also discovered that the JUMP_BACKWARD counter is initialized to 17 (the constant computed by adaptive_counter_warmup()), like all other counters, by _PyCode_Quicken() in specialize.c. Arguably, since this counter is supposed to count upwards from zero (in steps of 16, i.e. 1 << OPTIMIZER_BITS_IN_COUNTER), it ought to be initialized to zero (as I had expected it would be). But this ought to be a separate issue and PR.
Activity
gvanrossum commentedon Aug 22, 2023
@markshannon Do you have any idea what could be going on here? I'm afraid I don't completely understand what the failing test (
test_store_attr_with_hint) is doing.gvanrossum commentedon Aug 22, 2023
@markshannon I'm not at all sure I have the right fix (#108312 just disables the optimizer for the duration of the one test).
It looks like there's some non-determinism between the specialization of
LOAD_ATTRand the optimizer onJUMP_BACKWARD-- if the latter runs first,LOAD_ATTRwill never be specialized. But the question is, why would this happen sometimes but not all the time? When looking into it a few days ago in more detail, IIRC I found that 1 out of 1000 runs had this problem, where every other run had the correct specialization.) Maybe some counter does not get deterministically reset by.replace()?gvanrossum commentedon Aug 25, 2023
I think we do need to disable the executor-based optimizer for these tests. I observed that this loop in
assert_specializedgets translated into a superblock, tracing into the read() function:
before read() has had a chance to specialize its STORE_ATTR (which is currently a viable Tier 2 opcode). So then the subsequent assert_specialized() call fails.
Note that the tracing into read() stops when it encounters the JUMP_BACKWARD of the loop in read(); but it has already executed the unspecialized STORE_ATTR at that point, and it keeps doing so (during the warmup phase), until that JUMP_BACKWARD itself gets translated to Tier 2.
The solution is to just disable the Tier 2 optimizer in the entire assert_races_do_not_crash() function.
FWIW I also discovered that the JUMP_BACKWARD counter is initialized to 17 (the constant computed by adaptive_counter_warmup()), like all other counters, by
_PyCode_Quicken()in specialize.c. Arguably, since this counter is supposed to count upwards from zero (in steps of 16, i.e.1 << OPTIMIZER_BITS_IN_COUNTER), it ought to be initialized to zero (as I had expected it would be). But this ought to be a separate issue and PR.gh-108311: Fix test_store_attr_with_hint by disabling optimizer in de…