-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
gh-111968: Use per-thread freelists for dict in free-threading #114323
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 6 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
8561efc
gh-111968: Use per-thread freelists for dict in free-threading
corona10 6a69d6f
Address code review
corona10 b2d4606
Update Objects/dictobject.c
corona10 8889072
nit
corona10 0cecf66
Remove duplicated DICT_MAX_WATCHERS
corona10 7041d4a
nit
corona10 e973352
Address code review
corona10 514a66f
Remove unnecessary changes
corona10 c731cd3
Merge remote-tracking branch 'upstream/main' into gh-111968-dict
corona10 ef2b754
Address code review
corona10 e038141
Fix slash
corona10 e808bab
Address code review
corona10 d5fbbea
Merge remote-tracking branch 'upstream/main' into gh-111968-dict
corona10 e91d8ff
Address code review
corona10 b905692
Address code review
corona10 4f7d921
Address code review
corona10 9239cdc
Address code review
corona10 c12b1c1
Improve comments
corona10 ccd3b24
Address code review
corona10 9eff9a9
Merge remote-tracking branch 'upstream/main' into gh-111968-dict
corona10 e1d9549
nit
corona10 4a76399
Revert _PyDict_Fini
corona10 11f81d1
fix
corona10 86e3228
Address code review
corona10 42a3541
fix
corona10 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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#ifndef Py_INTERNAL_DICT_STATE_H | ||
#define Py_INTERNAL_DICT_STATE_H | ||
#ifndef Py_INTERNAL_GLOBAL_DICT_STATE_H | ||
#define Py_INTERNAL_GLOBAL_DICT_STATE_H | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
@@ -8,33 +8,14 @@ extern "C" { | |
# error "this header requires Py_BUILD_CORE define" | ||
#endif | ||
|
||
|
||
#ifndef WITH_FREELISTS | ||
// without freelists | ||
# define PyDict_MAXFREELIST 0 | ||
#endif | ||
|
||
#ifndef PyDict_MAXFREELIST | ||
# define PyDict_MAXFREELIST 80 | ||
#endif | ||
|
||
#define DICT_MAX_WATCHERS 8 | ||
|
||
struct _Py_dict_state { | ||
struct _Py_global_dict_state { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe In some places we use "global_state" to mean runtime-global (not interpreter). For example, we have:
|
||
/*Global counter used to set ma_version_tag field of dictionary. | ||
* It is incremented each time that a dictionary is created and each | ||
* time that a dictionary is modified. */ | ||
uint64_t global_version; | ||
uint32_t next_keys_version; | ||
|
||
#if PyDict_MAXFREELIST > 0 | ||
/* Dictionary reuse scheme to save calls to malloc and free */ | ||
PyDictObject *free_list[PyDict_MAXFREELIST]; | ||
PyDictKeysObject *keys_free_list[PyDict_MAXFREELIST]; | ||
int numfree; | ||
int keys_numfree; | ||
#endif | ||
|
||
PyDict_WatchCallback watchers[DICT_MAX_WATCHERS]; | ||
}; | ||
|
||
|
@@ -47,4 +28,4 @@ struct _Py_dict_state { | |
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif /* !Py_INTERNAL_DICT_STATE_H */ | ||
#endif /* !Py_INTERNAL_GLOBAL_DICT_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
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.