-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-110693: refactor pending calls and use linked list implementation #125567
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
base: main
Are you sure you want to change the base?
Conversation
74ac0c7 to
0820a7d
Compare
ce6bd79 to
78c6ee2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I think this is the right idea. There are a few things to consider:
- we still want to keep a statically allocated array for the main pending calls
- we need to be cautious as we switch to an unbounded linked list, and make it easy to dial it back if needed
- consider starting off with a "max" and making it unbounded in a separate PR
- there isn't much reason to change the tests, consider leaving them alone
| /* We keep the number small to preserve as much compatibility | ||
| as possible with earlier versions. */ | ||
| #define MAXPENDINGCALLS_MAIN 32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This point is still valid, so we should probably leave nearly all of the "main" pending calls stuff alone.
| run at once, for the sake of prompt signal handling. This is | ||
| unlikely to cause any problems since there should be very few | ||
| pending calls for the main thread. */ | ||
| #define MAXPENDINGCALLSLOOP_MAIN 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably leave this alone, but I'm not opposed to this change.
| /* The maximum allowed number of pending calls. | ||
| If the queue fills up to this point then _PyEval_AddPendingCall() | ||
| will return _Py_ADD_PENDING_FULL. */ | ||
| int32_t max; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should leave this, for the sake of the "main" pending calls stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also be worth leaving it for a while, so we can more easily deal with unexpected consequences of switching to an unbounded linked list.
| A value of 0 means there is no limit (other than the maximum | ||
| size of the list of pending calls). */ | ||
| int32_t maxloop; | ||
| struct _pending_call calls[PENDINGCALLSARRAYSIZE]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should leave this statically allocated array for the sake of the "main" pending calls. We could go back to the old limit of MAXPENDINGCALLS_MAIN though.
Of course, we'd still use this for per-interpreter pending calls, since it's already there.
| // For example, we use a preallocated array | ||
| // for the list of pending calls. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This point is still valid.
Uh oh!
There was an error while loading. Please reload this page.