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

Phase 3: Check thread arguments #39

Merged
merged 13 commits into from
Feb 2, 2025
Merged

Conversation

TobiasWrigstad
Copy link
Collaborator

@TobiasWrigstad TobiasWrigstad commented Jan 17, 2025

Adds a check to thread constructors ensuring that only cowns, immutables, and externally unique regions can be passed in as thread arguments.

There may be other things to check as well here but this is the MVP consistent with the paper.

Update these checks are now only run if the region invariant is enabled. This is probably a design we want to slightly revisit later.

Update 2 Clinic stuff is now sorted.

@TobiasWrigstad TobiasWrigstad force-pushed the cown-arguments-to-threads branch from 4826acf to d6c7f5e Compare January 17, 2025 23:18
@TobiasWrigstad TobiasWrigstad removed the request for review from xFrednet January 18, 2025 10:42
@TobiasWrigstad TobiasWrigstad force-pushed the cown-arguments-to-threads branch from 2a1c98d to 5783b7b Compare January 19, 2025 09:00
mjp41
mjp41 previously approved these changes Jan 19, 2025
Copy link
Owner

@mjp41 mjp41 left a comment

Choose a reason for hiding this comment

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

LGTM

builtin_is_pyrona_program_impl(PyObject *module)
/*[clinic end generated code: output=2b6729469da00221 input=d36655a3dc34a881]*/
{
return Py_is_invariant_enabled() ? Py_True : Py_False;
Copy link
Owner

Choose a reason for hiding this comment

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

Does feel like a bit of abuse of notions. I think putting a TODO here, se that we don't merge phase 3 without revisiting. Really I think we want a has used Pyrona, and that is the name of the flag that is used to determine if we should do the region check.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I fully agree. Will add the TODO as you suggest.

Copy link
Collaborator

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

Changes LGTM, mostly small comments and thoughts :)

@mjp41
Copy link
Owner

mjp41 commented Jan 21, 2025

I think for this, we should ultimately have a different thread start function that gives us DRF.

This can initially be just the same as this, and check the arguments. When we add multi-core, this can then dispatch to a difference core/interpreter, and will have a different local region.

Then we would get to a point, where all threads on an interpreter are potentially racing, and across interpreters they aren't. This would give a good migration story.

I think this is fine for now, but we should add comments, that we are going to back out these changes, and add a new API call that code should migrate too.

@mjp41 mjp41 dismissed their stale review January 21, 2025 15:04

I think we should revisit this design and possibly have a separate call for DRF thread creation.

@mjp41 mjp41 changed the title Check thread arguments Phase 3:Check thread arguments Jan 21, 2025
@mjp41 mjp41 changed the title Phase 3:Check thread arguments Phase 3: Check thread arguments Jan 21, 2025
@TobiasWrigstad TobiasWrigstad force-pushed the cown-arguments-to-threads branch from 1328d22 to 7ff6238 Compare January 27, 2025 19:45
@TobiasWrigstad
Copy link
Collaborator Author

I think for this, we should ultimately have a different thread start function that gives us DRF.

Agreed. I have now created a separate function PyronaThread that is defined in our using.py library and that starts a DRF thread. The standard threading.py library is reverted back to Python 3.12.0.

This can initially be just the same as this, and check the arguments. When we add multi-core, this can then dispatch to a difference core/interpreter, and will have a different local region.

Then we would get to a point, where all threads on an interpreter are potentially racing, and across interpreters they aren't. This would give a good migration story.

👍

I think this is fine for now, but we should add comments, that we are going to back out these changes, and add a new API call that code should migrate too.

I've added a comment on PyronaThread in using.py.

@TobiasWrigstad TobiasWrigstad force-pushed the cown-arguments-to-threads branch from a5ff8c5 to 4245516 Compare January 27, 2025 19:55
@TobiasWrigstad TobiasWrigstad force-pushed the cown-arguments-to-threads branch from 4245516 to 250fa97 Compare January 27, 2025 20:18
Comment on lines 2818 to 2819
/*[clinic input]
is_pyrona_program as builtin_is_pyrona_program
Copy link
Owner

Choose a reason for hiding this comment

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

I this used anymore? Should it still be part of this PR? I think now there is a separate API, we don't need to expose this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. I will remove it!

@TobiasWrigstad
Copy link
Collaborator Author

@mjp41 I've addressed your comments including adding +1 to the RCs due to your refactoring (I recall now that I did not make that refactoring to begin with to lower the RC's by one, but I'd already forgotten and someone will make this improvement in the future and get hit so better bite the bullet now). I think this is ready to go in!

Copy link
Owner

@mjp41 mjp41 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for updating the PR

@TobiasWrigstad TobiasWrigstad merged commit 5dd78bc into phase3 Feb 2, 2025
8 of 9 checks passed
@TobiasWrigstad TobiasWrigstad deleted the cown-arguments-to-threads branch February 2, 2025 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants