-
Notifications
You must be signed in to change notification settings - Fork 45
Next Event on Task struct #212
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
870fd91 to
a8eab76
Compare
|
Just for the record I'm generally pro |
|
Could we get #210 merged and then get this one out in a reviewable format? |
a8eab76 to
68f6332
Compare
61edacc to
5f487b5
Compare
5f487b5 to
15bc231
Compare
| unsafe { std::mem::transmute(&self.next_event) } | ||
| } | ||
|
|
||
| pub(crate) unsafe fn set_next_event(&mut self, event: Event<'_>) { |
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.
SAFETY comment describing how to make it safe. Also describe why unsafe is needed
15bc231 to
0840b5d
Compare
|
Did a "local review" now, making a commit instead of writing comments (since Dylan's internship is over, I'll be driving the PR to merge). Most of my changes are nits, but: I am not convinced the Related to this, I believe there is a race on the Re it not being safe: Re it being racy: How to fix: There's a few different ways of solving this. We could refactor the entire solution into not using Thus, we still need a way to set the event and also a a way to accommodate multiple events. It is perfectly valid to try to acquire one The immediate way I can think of to solve that is to add something in the All this said: I am not a big fan of how easy violating the SAFETY contract was, which I guess is true for a lot of unsafe. I do generally agree with Dylan in his comments above about cc @jorajeev |
|
@sarsko Thanks for the detailed writeup. I need some more time to think about all of it, but as a quick alternative option to get rid of the unsafe: we could create a small |
Currently, Shuttle schedulers have no visibility into the system under test. The algorithms only see which tasks are enabled at a given time, not what those tasks are actually doing. This lack of semantic information greatly limits what we can do with Shuttle schedulers. Many algorithms, such as Partial Order Sampling (POS) and Selective Uniform Random Walk (SURW) leverage information about the events being executed to make better scheduling decisions (e.g. make a different decision if two events conflict, or if a particular task is accessing a resource “of interest”). Such information is also useful for developing a general notion of behavioral coverage — for example, tracking new reads-from edges.
This PR adds a
next_eventfield to the Task struct, which is accessible to scheduling algorithms. The Event enum gives the schedulers access to the signature of the resource being accessed, as well as the source location of the access (viatrack_caller).As a small "demo" application, I also modified the Metrics scheduler to count the number and kind of events observed during a Shuttle test. As part of this demo, I did make some light changes to the Scheduler API so that it returns a &Task instead of a TaskId. This change allows nested schedulers such as the Metrics scheduler to directly lookup information about the task chosen by inner schedulers without iterating over the runnable tasks.
Note: this PR does use some unsafe lifetime casting to allow Task to hold a reference to the Task/Resource signatures. Just outright cloning the signatures is maybe ~5-8% slower in the worst case. I'm open to discussion/suggestions here, but I think the other approaches to avoid cloning without unsafe might end up being significantly more complicated than the unsafe code without much real benefit. In particular, using
Rc<_>for signatures requires heap allocations on initialization, while many resource constructors areconst. Note that this is similar to the unsafe added for the runnable tasks slice, and, as in that case, we are providing a safe API to the scheduling algorithms.I am marking this as a draft for now because it depends on
two other open PRs (#207 and #210)#216.It currently includes the changes from these other PRs. To look at the changes unique to this PR, see 4778a31I've rebased this on #216, will mark as ready for review as soon as that is merged
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.