Skip to content

Perf: one thread-state and one TLS lookup per compiled call (#125) - #273

Merged
b-re-w merged 2 commits into
developfrom
feat/tp-tstate
Oct 25, 2026
Merged

b-re-w merged 2 commits into
developfrom
feat/tp-tstate

Conversation

@b-re-w

@b-re-w b-re-w commented Oct 24, 2026

Copy link
Copy Markdown
Member

Refs #125 (option 1 of 3 unobservable improvements; direct slot access and cheaper N-11 dealloc follow).

tp_wrap_* takes PyThreadState_GetUnchecked() and the per-thread tp_tls struct (depth, poll countdown, snapshot depth, merged from three __thread variables) once and passes both down to impls, fast twins and direct callees. Py_EnterRecursiveCall/Py_LeaveRecursiveCall keep their own lookup (no public tstate variant). Recursion depth unchanged (965, same as interpreted). Test: at most one lookup per wrapper, none in impls. Tests: recursion 14, eval_breaker 8, tracing 11, runtime 264, cgen 59, fast_entry 11, str_dict 29. Timing inconclusive at load 20. Merge held for the macOS runner freeze.

@b-re-w
b-re-w merged commit 7c0d63f into develop Oct 25, 2026
@b-re-w
b-re-w deleted the feat/tp-tstate branch October 25, 2026 00:15
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.

1 participant