Skip to content
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

gh-112075: Add a little specialization thread safety #114768

Closed
wants to merge 1 commit into from

Conversation

DinoV
Copy link
Contributor

@DinoV DinoV commented Jan 30, 2024

A couple of specializations call into dict apis w/o a lock and are doing multiple reads. This is just a small change to protect those reads with the dict lock.

@DinoV DinoV force-pushed the nogil_dict_module_specialization branch from ded73c4 to a857147 Compare January 31, 2024 00:08
@DinoV DinoV changed the title gh-112075: Lock dict when specializing module lookup gh-112075: Add a little specialization thread safety Jan 31, 2024
@DinoV DinoV force-pushed the nogil_dict_module_specialization branch from a857147 to dc19c16 Compare January 31, 2024 00:26
@DinoV DinoV marked this pull request as ready for review January 31, 2024 01:32
Copy link
Contributor

@colesbury colesbury left a comment

Choose a reason for hiding this comment

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

This looks okay to me and should not have any effect on the default build.

However, I think we should generally hold off on incremental thread-safety changes to specialization until the dict thread-safe changes are done. I find it hard to tell how these sorts of changes will interact.

Comment on lines +847 to +848
int res;
Py_BEGIN_CRITICAL_SECTION(dict);
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 this might be easier to read if it is refactored out into it's own function.

@DinoV DinoV closed this May 31, 2024
@DinoV DinoV deleted the nogil_dict_module_specialization branch May 31, 2024 18:23
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