gh-148223: Avoid unnecessary NotShareableError in XIData FULL_FALLBACK#148224
Open
jrfk wants to merge 1 commit intopython:mainfrom
Open
gh-148223: Avoid unnecessary NotShareableError in XIData FULL_FALLBACK#148224jrfk wants to merge 1 commit intopython:mainfrom
jrfk wants to merge 1 commit intopython:mainfrom
Conversation
…ALLBACK Skip _get_xidata() for types not in the XIData registry when using the FULL_FALLBACK path in _PyObject_GetXIData(). This avoids creating and discarding a NotShareableError exception on every successful pickle fallback transfer. Registered types (None, bool, int, float, str, bytes, tuple) still follow the existing path unchanged. On total failure, the same NotShareableError is raised as before.
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.
Summary
Avoid unnecessary
NotShareableErrorcreation in_PyObject_GetXIData()on theFULL_FALLBACKpath.For types not present in the XIData registry, the previous code always called
_get_xidata(), which raisedNotShareableErrorbefore falling back to function/pickle handling. When pickle fallback succeeded, that exception was immediately discarded. This change adds a registry pre-check so unregistered types can skip_get_xidata()and go straight to the fallback path.Follow-up to gh-148072 / GH-148125 (pickle cache).
Changes
FULL_FALLBACKbranch inPython/crossinterp.clookup_getdata()before calling_get_xidata()NotShareableErrorbehavior on total failureBehavior
This is intended as a performance-only change.
NotShareableErroris raised as in the non-optimized pathBenchmarks
Baseline is
upstream/main(after GH-148125).identity(x)round-trip,max_workers=1, Apple M2.list(100)dict(100)list(10000)dict(10000)Test plan
./python -m test test_interpreters— 172 tests passed./python -m test test_concurrent_futures— 380 tests passed (includingtest_interpreter_pool)