Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

GH-114695: Addsys._clear_internal_caches#115152

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
markshannon merged 20 commits intopython:mainfrombrandtbucher:tier-two-leaks
Feb 12, 2024

Conversation

brandtbucher
Copy link
Member

@brandtbucherbrandtbucher commentedFeb 8, 2024
edited by github-actionsbot
Loading

This new function immediately releases all tier-two related references and memory, which is useful for refleak-hunting.

Currently, invalid executors need to be hit again in order to be cleared (which may never happen), and there is no way to free the code object's executor array. This PR adds a (weak) pointer from executors back to the code object they're installed in, which allows them to immediately remove themselves upon invalidation. Code objects can clear this pointer if the executor outlives them.

This PR also changes the linked list to contain every valid executor, and no invalid ones. That means that the oldlinked member is redundant with thevalid field, so it's removed.


📚 Documentation preview 📚:https://cpython-previews--115152.org.readthedocs.build/

@brandtbucherbrandtbucher added type-bugAn unexpected behavior, bug, or error testsTests in the Lib/test dir interpreter-core(Objects, Python, Grammar, and Parser dirs) labelsFeb 8, 2024
@brandtbucherbrandtbucher self-assigned thisFeb 8, 2024
Copy link
Member

@markshannonmarkshannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The code looks good, but I have a couple of concerns.

  1. I don't like exposing low-level implementation details like executors though, so could we renamesys._clear_executors()?
    Maybe merge it withsys._clear_type_cache() into something likesys._clear_internal_caches()?
    That way we can add other caches, jitted code, etc. and clear them all without changing the API.

  2. We might want to invalidate a lot of executors in a stop-the-world event. Merely setting thevalid flag to zero (as we do now) is fine, but freeing lots of object may not be. Can we go back to invalidating executors not doing much work, and leaving clean up to later?

_PyBloomFilter bloom;
_PyExecutorLinkListNode links;
PyCodeObject *code; // Weak (NULL if no corresponding ENTER_EXECUTOR).
int index; // Index of ENTER_EXECUTOR in the above code object.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you move this above the bloom filter, to avoid holes?

brandtbucher reacted with thumbs up emoji
exec->vm_data.valid = false;
exec->vm_data.linked = false;
exec = next;
_PyExecutorObject *executor;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What's the reason for moving the declaration out of the loop?

Copy link
MemberAuthor

@brandtbucherbrandtbucherFeb 9, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is a while loop now.

Would you prefer to leave it as a for loop? It's a tiny bit more repetitive, but maybe easier to follow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The for loop is nice as it limits the scope of the iteration variable. It doesn't matter much.

@brandtbucherbrandtbucher changed the titleGH-114695: Addsys._clear_executorsGH-114695: Addsys._clear_internal_cachesFeb 10, 2024
@brandtbucherbrandtbucher requested a review froma team as acode ownerFebruary 10, 2024 01:29
@offensive-vk
Copy link

I'm Sorry, mistakenly clicked on review button.
Sorry for the inconvenience.

@markshannonmarkshannon merged commit235cacf intopython:mainFeb 12, 2024
fsc-eriker pushed a commit to fsc-eriker/cpython that referenced this pull requestFeb 14, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@markshannonmarkshannonmarkshannon approved these changes

@offensive-vkoffensive-vkoffensive-vk approved these changes

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

@gvanrossumgvanrossumAwaiting requested review from gvanrossum

Assignees

@brandtbucherbrandtbucher

Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@brandtbucher@offensive-vk@markshannon

[8]ページ先頭

©2009-2025 Movatter.jp