-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Refine specialization caches and extend binary-op coverage #7386
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
Merged
+795
−473
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5393e86
Align BINARY_OP_EXTEND with CPython descriptor cache model
youknowone 5bc6078
Align type _spec_cache and latin1 singleton string paths
youknowone cb156c1
Add specialization differential harness and align init error text
youknowone fc4728b
Tighten CALL_ALLOC_AND_ENTER_INIT stack-space guard
youknowone c487b6d
Align call-init frame flow and spec cache atomic ordering
youknowone 2dd64b8
Refine call-init recursion guard and cache swap lifetime handling
youknowone a0c302c
Align spec cache write locking with CPython contract
youknowone ceefe6e
rename
youknowone 2d7cb74
address review: invalidate init cache on type modification, add cspel…
youknowone f7924dd
Align load attr miss cooldown with CPython
youknowone 138d48e
Align CALL descriptor and class-call specialization with CPython
youknowone aa9f5a8
address review: check datastack space for extra_bytes, require CO_OPT…
youknowone a277b86
Extract datastack_frame_size_bytes_for_code, skip monitoring for init…
youknowone dbd8b1a
Fix Constants newtype usage in init_cleanup_code
youknowone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the runtime closure length when sizing datastack frames.
Frame::new()sizeslocalspluswithclosure.len(), but this helper hard-codescode.freevars.len(). Sinceset___code__still allows swapping in a code object without revalidating the stored closure, callers that reserve datastack space via this helper can compute a smaller layout thanprepare_exact_args_frame()will actually allocate.Possible direction
pub(crate) fn datastack_frame_size_bytes(&self) -> Option<usize> { - datastack_frame_size_bytes_for_code(&self.code) + datastack_frame_size_bytes_for_layout( + &self.code, + self.closure.as_ref().map_or(0, |c| c.len()), + ) } -pub(crate) fn datastack_frame_size_bytes_for_code(code: &Py<PyCode>) -> Option<usize> { +pub(crate) fn datastack_frame_size_bytes_for_layout( + code: &Py<PyCode>, + nfrees: usize, +) -> Option<usize> { if code .flags .intersects(bytecode::CodeFlags::GENERATOR | bytecode::CodeFlags::COROUTINE) { return None; } let nlocalsplus = code .varnames .len() .checked_add(code.cellvars.len())? - .checked_add(code.freevars.len())?; + .checked_add(nfrees)?; let capacity = nlocalsplus.checked_add(code.max_stackdepth as usize)?; capacity.checked_mul(core::mem::size_of::<usize>()) }🤖 Prompt for AI Agents