Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

GH-126491: Lower heap size limit with faster marking #127519

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 24 commits into from
Dec 6, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3038a78
Faster marking of reachable objects
markshannon Nov 9, 2024
c024484
Handle more classes in fast marking
markshannon Nov 10, 2024
e8497ae
Add support for asyn generators on fast path. Simplify counting
markshannon Nov 11, 2024
4c1a6bc
Check stackref before converting to PyObject *
markshannon Nov 11, 2024
6efb4c0
Rename stuff
markshannon Nov 13, 2024
b1c7ab0
Remove expand_region_transitively_reachable and use move_all_transiti…
markshannon Nov 13, 2024
07f228b
Merge branch 'main' into faster-marking
markshannon Dec 2, 2024
51ff78e
Fix compiler warnings and linkage
markshannon Dec 2, 2024
df907b5
Fix another linkage issue
markshannon Dec 2, 2024
9ca64f5
Try 'extern'
markshannon Dec 2, 2024
bda13f4
Go back to PyAPI_FUNC and move functions together
markshannon Dec 2, 2024
d9d63c8
Use _Py_FALLTHROUGH
markshannon Dec 2, 2024
57b8820
Add necessary #ifndef Py_GIL_DISABLED
markshannon Dec 2, 2024
a607059
Go back to using tp_traverse, but make traversal more efficient
markshannon Dec 3, 2024
1545508
Tidy up
markshannon Dec 3, 2024
a1a38c8
A bit more tidying up
markshannon Dec 3, 2024
68fc90b
Move all work to do calculations to one place
markshannon Dec 3, 2024
8893cf5
Assume that increments are 50% garbage for work done calculation
markshannon Dec 3, 2024
ba20c7c
Elaborate comment
markshannon Dec 4, 2024
8262bf0
More tweaking of thresholds
markshannon Dec 4, 2024
3c2116e
Do some algebra
markshannon Dec 4, 2024
72d0284
Revert to 2M+I from 3M+I
markshannon Dec 4, 2024
0f182e2
Address review comments
markshannon Dec 5, 2024
d3c21bb
Address review comments and clarify code a bit
markshannon Dec 5, 2024
File filter

Filter by extension

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
Faster marking of reachable objects
  • Loading branch information
markshannon committed Nov 18, 2024
commit 3038a78fc50757dce9ec2ae50a19708a7a9bed42
70 changes: 65 additions & 5 deletions 70 Python/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,7 @@ move_to_reachable(PyObject *op, PyGC_Head *reachable, int visited_space)
return 0;
}


static Py_ssize_t
mark_all_reachable(PyGC_Head *reachable, PyGC_Head *visited, int visited_space)
{
Expand All @@ -1442,18 +1443,77 @@ mark_all_reachable(PyGC_Head *reachable, PyGC_Head *visited, int visited_space)
.visited_space = visited_space,
.size = 0
};
Py_ssize_t objects_marked = 0;
while (!gc_list_is_empty(reachable)) {
PyGC_Head *gc = _PyGCHead_NEXT(reachable);
assert(gc_old_space(gc) == visited_space);
gc_list_move(gc, visited);
PyObject *op = FROM_GC(gc);
traverseproc traverse = Py_TYPE(op)->tp_traverse;
(void) traverse(op,
visit_add_to_container,
&arg);
assert(PyObject_IS_GC(op));
switch(Py_TYPE(op)->tp_version_tag) {
case _Py_TYPE_VERSION_LIST:
{
PyListObject *o = (PyListObject *)op;
Py_ssize_t i;
for (i = Py_SIZE(o); --i >= 0; ) {
PyObject *item = o->ob_item[i];
objects_marked += move_to_reachable(item, reachable, visited_space);
}
break;
}
case _Py_TYPE_VERSION_TUPLE:
{
PyTupleObject *o = (PyTupleObject *)op;
for (Py_ssize_t i = Py_SIZE(o); --i >= 0; ) {
PyObject *item = o->ob_item[i];
objects_marked += move_to_reachable(item, reachable, visited_space);
}
break;
}
case _Py_TYPE_VERSION_DICT:
{
PyDictObject *mp = (PyDictObject *)op;
PyDictKeysObject *keys = mp->ma_keys;
Py_ssize_t i, n = keys->dk_nentries;
if (DK_IS_UNICODE(keys)) {
if (_PyDict_HasSplitTable(mp)) {
if (!mp->ma_values->embedded) {
for (i = 0; i < n; i++) {
PyObject *value = mp->ma_values->values[i];
objects_marked += move_to_reachable(value, reachable, visited_space);
}
}
}
else {
PyDictUnicodeEntry *entries = DK_UNICODE_ENTRIES(keys);
for (i = 0; i < n; i++) {
PyObject *value = entries[i].me_value;
objects_marked += move_to_reachable(value, reachable, visited_space);
}
}
}
else {
PyDictKeyEntry *entries = DK_ENTRIES(keys);
for (i = 0; i < n; i++) {
if (entries[i].me_value != NULL) {
PyObject *key = entries[i].me_key;
objects_marked += move_to_reachable(key, reachable, visited_space);
PyObject *value = entries[i].me_value;
objects_marked += move_to_reachable(value, reachable, visited_space);
}
}
}
break;
}
default:
{
traverseproc traverse = Py_TYPE(op)->tp_traverse;
(void) traverse(op, visit_add_to_container, &arg);
}
}
}
gc_list_validate_space(visited, visited_space);
return arg.size;
return objects_marked + arg.size;
}

static Py_ssize_t
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.