-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
gh-100240: Use a consistent implementation for freelists #121934
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
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f1e7867
gh-100240: Use a consistent implementation for freelists
colesbury a4dfb45
Add files to MSVC project
colesbury 995c306
Revert a few stray changes
colesbury 85453d0
Remove unused include
colesbury a90b05f
Update Include/internal/pycore_freelist.h
colesbury aa8e4d5
Merge branch 'main' into gh-100240-freelist
colesbury 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
Next
Next commit
gh-100240: Use a consistent implementation for freelists
This combines and updates our freelist handling to use a consistent implementation. Objects in the freelist are linked together using the first word of memory block. If configured with freelists disabled, these operations are essentially no-ops.
- Loading branch information
commit f1e7867763340a38b7f693ea6963077b28fab140
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| #ifndef Py_INTERNAL_FREELIST_STATE_H | ||
| #define Py_INTERNAL_FREELIST_STATE_H | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| #ifndef Py_BUILD_CORE | ||
| # error "this header requires Py_BUILD_CORE define" | ||
| #endif | ||
|
|
||
| #ifdef WITH_FREELISTS | ||
| // with freelists | ||
| # define PyTuple_MAXSAVESIZE 20 // Largest tuple to save on freelist | ||
| # define Py_tuple_MAXFREELIST 2000 // Maximum number of tuples of each size to save | ||
| # define Py_lists_MAXFREELIST 80 | ||
| # define Py_dicts_MAXFREELIST 80 | ||
| # define Py_dictkeys_MAXFREELIST 80 | ||
| # define Py_floats_MAXFREELIST 100 | ||
| # define Py_slices_MAXFREELIST 1 | ||
| # define Py_contexts_MAXFREELIST 255 | ||
| # define Py_async_gens_MAXFREELIST 80 | ||
| # define Py_async_gen_asends_MAXFREELIST 80 | ||
| # define Py_object_stack_chunks_MAXFREELIST 4 | ||
| #else | ||
| # define PyTuple_MAXSAVESIZE 0 | ||
| #endif | ||
|
|
||
| // A generic freelist of either PyObjects or other data structures. | ||
| struct _Py_freelist { | ||
| // Entries are linked together using the first word of the the object. | ||
| // For PyObjects, this overlaps with the `ob_refcnt` field or the `ob_tid` | ||
| // field. | ||
| void *freelist; | ||
|
|
||
| // The number of items in the free list or -1 if the free list is disabled | ||
| Py_ssize_t size; | ||
| }; | ||
|
|
||
| struct _Py_freelists { | ||
| #ifdef WITH_FREELISTS | ||
| struct _Py_freelist floats; | ||
| struct _Py_freelist tuples[PyTuple_MAXSAVESIZE]; | ||
| struct _Py_freelist lists; | ||
| struct _Py_freelist dicts; | ||
| struct _Py_freelist dictkeys; | ||
| struct _Py_freelist slices; | ||
| struct _Py_freelist contexts; | ||
| struct _Py_freelist async_gens; | ||
| struct _Py_freelist async_gen_asends; | ||
| struct _Py_freelist object_stack_chunks; | ||
| #else | ||
| char _unused; // Empty structs are not allowed. | ||
| #endif | ||
| }; | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif /* !Py_INTERNAL_FREELIST_STATE_H */ |
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
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.
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.
Uh oh!
There was an error while loading. Please reload this page.