Convert ManagedThread to Rust#2812
Merged
sporksmith merged 10 commits intoshadow:mainfrom Mar 31, 2023
Merged
Conversation
8c01fa0 to
af8c5aa
Compare
Contributor
Author
|
Tor benchmark: https://github.com/shadow/benchmark/actions/runs/4569509748 |
sporksmith
commented
Mar 30, 2023
stevenengler
approved these changes
Mar 31, 2023
This has several issues to be fixed in follow-up commits in this PR, called out with "FIXME" comments.
This is the shortest route to avoiding double mutable borrows of the ManagedThread itself.
(This was missing in the C code)
Spawning a thread requires an owned copy of argv; pass ownership all the way through the stack instead of copying "on-demand".
We currently emulate all the supported operations on these, and ought to emulate any additional operations we later want to support, if any.
The shmem allocator doesn't support such large alignments. The safe Rust wrapper panics if the allocation doesn't happen to be aligned enough. It wouldn't have been giving us this alignment before either; we just didn't have the alignment validation when going through the C API. I already suspected the performance difference in the PR this was likely to have been some other artifact; it seems even more likely now. Removing it.
Also propagates this backwards a bit for some Thread APIs to take `&ProcessContext`. On one hand, this means passing along more "global" state than strictly necessary. OTOH I think this will help limit the pain of having to propagate fine-grained requiredments backwards through call stacks when we need one of these objects in some deeply nested function. I still left finer-grained parameters for non-pub APIs, since it's not as painful to refactor those within a single module.
This fixes a FIXME in `Thread` where we were getting the current `Process` and `Host` from the `Worker`. This propagates passing them explicitly instead, using e.g. `ThreadContext`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Probably easiest to review a commit at a time.
The first commit tries to do the "dumbest" conversion possible, while minimizing design changes. It includes several FIXMEs for things that are fixed in follow-up commits in this PR.
There's still room for more improvements and refactoring, but I think this is a good-enough point to merge.