gh-131798: Add tier-2 list specialization for STORE_SLICE#149446
Open
eendebakpt wants to merge 8 commits intopython:mainfrom
Open
gh-131798: Add tier-2 list specialization for STORE_SLICE#149446eendebakpt wants to merge 8 commits intopython:mainfrom
eendebakpt wants to merge 8 commits intopython:mainfrom
Conversation
Adds a tier-2 only `_STORE_SLICE_LIST` op and a guard `_GUARD_THIRD_LIST`, plus an optimizer rule that rewrites generic `_STORE_SLICE` to the list fast path when the LHS container is (or can be guarded as) an exact list. The list path calls a new `_PyList_StoreSlice` helper that adjusts the slice indices and dispatches into `list_ass_slice_lock_held` directly, skipping the slice-object allocation and the generic `PyObject_SetItem` lookup. The tier-1 `_STORE_SLICE` opcode is left unchanged so non-list callers incur no extra branch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Documentation build overview
43 files changed ·
|
Resolved generated pycore_uop_ids.h conflict by regenerating from bytecodes.c / optimizer_bytecodes.c. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The JIT currently dispatches
STORE_SLICE(container[start:stop] = value) throughPyObject_SetItemeven when the trace has proven the container is an exact list. Adding a tier-2 specialization_STORE_SLICE_LISTskips the slice-object allocation and the generic lookup.The optimizer rewrites
_STORE_SLICE→_STORE_SLICE_LISTonly when the container's type is statically known, so non-list callers and tier-1 are unaffected. A second commit forbytearraywas added but reverted.Benchmark results on pyperformance
fannkuch(tier-2 / JIT enabled):