Skip to content

gh-135474: Don't run the GC in the middle of longobject operations#135475

Closed
Fidget-Spinner wants to merge 2 commits into
python:mainfrom
Fidget-Spinner:no-gc-long
Closed

gh-135474: Don't run the GC in the middle of longobject operations#135475
Fidget-Spinner wants to merge 2 commits into
python:mainfrom
Fidget-Spinner:no-gc-long

Conversation

@Fidget-Spinner

@Fidget-Spinner Fidget-Spinner commented Jun 13, 2025

Copy link
Copy Markdown
Member

This is safe to do because we only allocate at the start of the operation, not in the midst of it. So the rss will never grow while we're checking for this.

Additionally, reading the comments in the codes suggest to me the point of checking for signals was for interrupts, not for GC.
So this should make things slightly faster.

@markshannon markshannon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure that we can do this safely.

I think we might need to restrict ourselves to specializing for compact ints and avoiding the potentially long-running big int versions of add/subtract and multiply.

Comment thread Modules/signalmodule.c
PyThreadState *tstate = _PyThreadState_GET();

#if defined(Py_REMOTE_DEBUG) && defined(Py_SUPPORTS_REMOTE_DEBUG)
_PyRunRemoteDebugger(tstate);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can do anything, so could easily cause the GC to run.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah drats. You're right. I will fix this by fixing the specialization then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants