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-143057: Use atomics for _PyRuntime.tracemalloc.config.tracing#143066

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

Closed
Yhg1s wants to merge1 commit intopython:mainfromYhg1s:tracemalloc_atomic_check

Conversation

@Yhg1s
Copy link
Member

@Yhg1sYhg1s commentedDec 22, 2025
edited by bedevere-appbot
Loading

Use atomics for the _PyRuntime.tracemalloc.config.tracing so we can bail early inPyTraceMalloc_Track andPyTraceMalloc_Untrack if tracemalloc isn't enabled. This avoids a significant scaling issue when tracemalloc isn't enabled, in extension modules that properly use the PyTraceMalloc_Track API (like numpy).

early in `PyTraceMalloc_Track` and `PyTraceMalloc_Untrack` if tracemallocisn't enabled. This avoids a significant scaling issue when tracemallocisn't enabled, in extension modules that properly use thePyTraceMalloc_Track API (like numpy).
/* everything is ready: start tracing Python memory allocations */
TABLES_LOCK();
tracemalloc_config.tracing=1;
_Py_atomic_store_int_release(&tracemalloc_config.tracing,1);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think release is stronger than necessary because there are no data dependencies. The actual functions are called with the lock held anyways so only atomicity oftracing matters.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I think thereis a hidden data dependency: we don't want tracing to be enabled, an allocation to be tracked, and then another thread deallocating that tracked data without untracking.

@Yhg1sYhg1s closed thisDec 22, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@kumaraditya303kumaraditya303kumaraditya303 left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@Yhg1s@kumaraditya303

[8]ページ先頭

©2009-2026 Movatter.jp