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

WIP: Add AppWorkload builder & Cycle checking #4

Merged
merged 20 commits into from
Jan 18, 2021

Conversation

colelawrence
Copy link
Member

Changes to enable detection of workload conflicts.

@colelawrence colelawrence merged commit 4c49da5 into master Jan 18, 2021
@colelawrence colelawrence deleted the dev/cl-2021-01/workload-cycle-checks branch January 18, 2021 16:57
Copy link
Contributor

@llogiq llogiq left a comment

Choose a reason for hiding this comment

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

A number of nits and some questions. 👍 on the test additions, and nice wins (the line numbers increase is due to adding Cargo.lock and tests).

README.md Show resolved Hide resolved
Comment on lines +33 to +35
pub fn add_plugin_workload<P>(&mut self, plugin: P) -> AppWorkload
where
P: Plugin + 'static,
Copy link
Contributor

Choose a reason for hiding this comment

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

I usually put the generics right in the definition if the line doesn't get too wide:

Suggested change
pub fn add_plugin_workload<P>(&mut self, plugin: P) -> AppWorkload
where
P: Plugin + 'static,
pub fn add_plugin_workload<P: Plugin + 'static>(&mut self, plugin: P) -> AppWorkload

Copy link
Member Author

Choose a reason for hiding this comment

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

The following fn (add_plugin_workload_with_info) has the same structure but does become too wide for one line, so I'm leaning towards the two signatures reading the same way.

self.add_plugin_workload_with_info(plugin).0
}

#[track_caller]
Copy link
Contributor

Choose a reason for hiding this comment

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

Does trace_span! obey #[track_caller]? Or is there any possible panic I overlooked?

Copy link
Member Author

Choose a reason for hiding this comment

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

builder.finish_with_info_named unwraps on the "add to world" step

use crate::{App, AppWorkload, AppWorkloadInfo, PluginAssociated, TypeIdBuckets};

#[derive(Clone)]
pub struct CyclePluginAssociations {
Copy link
Contributor

Choose a reason for hiding this comment

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

Some documentation would be nice. What's a cycle here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add some docs!

src/app_add_cycle.rs Show resolved Hide resolved
}
/// If you override this to return true, then you will be allowed to add your plugin multiple times.
fn can_add_multiple_times(&self) -> bool {
false
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If we decide to create a macro to build an impl for this, here would be a good place to put it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm... I feel like there's some niceties we could apply using a DSL of some kind, but the impls are pretty lightweight overall IMO.

}
}

unsafe impl<'a, T: 'static + Send + Sync> BorrowInfo for Tracked<'a, T> {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an interesting concept; but I don't understand what BorrowInfo does, yet. Note to self: Need to look into this at some point.

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't look too closely right now since it's being reworked a bit by @leudz.

Copy link
Contributor

Choose a reason for hiding this comment

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

BorrowInfo collects information about what each system borrows, this is used by WorkloadBuilder to decide scheduling inside a workload.
The borrow_info function was previously in Borrow, I moved it to its own trait to make it unsafe. I will add a way to bypass locking and trust the scheduler.
But the scheduler can only do correctly its job if BorrowInfo is implemented correctly.

enum InnerTrackedState {
New,
Modified,
NoChanges,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
NoChanges,
Unchanged,

Copy link
Member Author

Choose a reason for hiding this comment

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

Any precedent for this rename or just preference?


#[inline(always)]
fn deref(&self) -> &T {
&self.0 .1
Copy link
Contributor

Choose a reason for hiding this comment

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

load-bearing whitespace? Is some parser confused and thinks this was a float? rustc would accept &self.0.1.

Copy link
Member Author

Choose a reason for hiding this comment

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

cargo fmt / rustfmt did this, I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

src/tracked_unique.rs Show resolved Hide resolved
@llogiq
Copy link
Contributor

llogiq commented Jan 19, 2021

Oops! I just saw that you already merged. So perhaps there should be a followup PR.

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