Skip to content

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Jun 20, 2025

This is a reimplementation of #132533 (which I forgot about, sorry @iritkatriel) but with support for CALL_KW, CALL_FUNCTION_EX and a tier2 version that doesn't escape.

Initial benchmarking was about 0.5% slower across the platforms.

Stats showed that CHECK_PERIODIC was 7.1% of all instructions.

To mitigate this, this PR also:

  • Tracks if CHECK_PERIODIC has been emitted in a basic block, and not emit it twice without an intervening call.
  • Skips over CHECK_PERIODIC in CALL_PY_EXACT_ARGS and CALL_PY_GENERAL as they will have checked the eval breaker.
  • Modifies CALL_LIST_APPEND to check the eval breaker or this loop might never check the eval breaker:
for i in x:
   seq.append(i)

📚 Documentation preview 📚: https://cpython-previews--135772.org.readthedocs.build/

@markshannon markshannon changed the title GH_132532: Make CHECK_PERIODIC an instruction, not just a uop. GH-132532: Make CHECK_PERIODIC an instruction, not just a uop. Jun 20, 2025
@markshannon
Copy link
Member Author

Closing in favor of #137098 as that PR achieves the same result with no performance impact.

@markshannon markshannon deleted the explicit-check-periodic branch August 2, 2025 15:51
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.

1 participant