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

Remove send+sync requirement if not parallel #674

Merged
merged 9 commits into from
Feb 12, 2020

Conversation

chinedufn
Copy link
Contributor

Closes #673

@@ -27,7 +27,7 @@ derivative = "1"
hashbrown = "0.6.0"
hibitset = { version = "0.6.1", default-features = false }
log = "0.4"
shred = { version = "0.9.3", default-features = false }
shred = { version = "0.10.1", default-features = false }
Copy link
Contributor Author

@chinedufn chinedufn Jan 24, 2020

Choose a reason for hiding this comment

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

shred 0.10.1 needs to be deployed before this PR can be merged

amethyst/shred#186

Cargo.toml Outdated
@@ -39,7 +39,6 @@ uuid = { version = "0.7.4", optional = true, features = ["v4", "serde"] }
[features]
default = ["parallel"]
parallel = ["rayon", "shred/parallel", "hibitset/parallel"]
nightly = ["shred/nightly"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A breaking change so I bumped the minor version of specs

We could also leave this feature in and just make it nightly = [] if we don't want to bump to 0.16 just yet - then I can just make this PR bump to 0.15.2

Whatever works for specs!

@chinedufn chinedufn force-pushed the non-send-sync-resources branch 2 times, most recently from b1c766c to 9b12b28 Compare January 24, 2020 16:27
Copy link
Member

@azriel91 azriel91 left a comment

Choose a reason for hiding this comment

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

Heya, the changes in both PRs look good to these eyes; could you also add a test that the non-"parallel" version builds with a !Send + !Sync type? Maybe just checking that adding a struct NonSend(pub Rc<u32>) to the World would suffice.

@azriel91
Copy link
Member

azriel91 commented Feb 3, 2020

Heya, took a while to get back, but the changes in both PRs look good to me.

In terms of repository ownership, I don't yet feel like I'm "the one", else I'd be happy to take them.
@WaDelma since @torkleyy's focusing on other things, would you mind me making decisions at this level? am also happy to tag you whenever this kind of decision needs to be made (usually directional, rather than technical).

@WaDelma
Copy link
Member

WaDelma commented Feb 4, 2020

@chinedufn tbh I have never felt like being "the one" either and have been bit afraid of stepping on other peoples toes accidentally, so I am happy to let you be it. I can participate on things though!

@azriel91 azriel91 mentioned this pull request Feb 11, 2020
4 tasks
@azriel91
Copy link
Member

@chinedufn I've tried getting specs to be tested with the shred change in #677, but Rust isn't happy yet:

$ cargo test --no-default-features --workspace                                                                                                                                                                                                
# ..
error: aborting due to 55 previous errors
# ..

Could you check what's blocking that? I haven't merged shred's PR because I'd like to see it working end-to-end first (instead of merge/release and needing to yank versions).

@chinedufn
Copy link
Contributor Author

chinedufn commented Feb 11, 2020

@azriel91 sorry about that - d74d02b makes the following pass

git clone https://github.com/chinedufn/specs
cd specs
git checkout origin/non-send-sync-resources
git checkout d74d02b724529994c729ea8a5c4a3f897e2d1655
cargo test --workspace && \
  cargo test --no-default-features --workspace

@@ -1,9 +1,11 @@
extern crate rand;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opted for the quick approach to get things passing with the parallel feature disabled by just panicking.

I thought that the work of making the examples work in parallel and non-parallel could be left for the future since these wouldn't have worked in not(parallel) before anyway

examples/full.rs Outdated
@@ -1,4 +1,6 @@
#[cfg(feature = "parallel")]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same idea here - quick and dirty approach of panicking when not parallel

@@ -0,0 +1,14 @@
#![cfg(not(feature = "parallel"))]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@azriel91 addresses #674 (review) - thanks for the feedback!

@azriel91
Copy link
Member

ah oops, I did similar changes in #677 (but didn't force push to your branch -- in case you still wanted it).

oh. just discovered why -- [dev-dependencies] didn't have default-features = false for shred. Shall push that one over this branch soon (shall release shred).

@azriel91
Copy link
Member

azriel91 commented Feb 12, 2020

Goal: Support Components that are not Send + Sync.

There is a test in tests/no_parallel.rs to prove the goal is reached when "parallel" is disabled. Existing tests prove when "parallel" is enabled.

  • Ideal solution: Trait aliases, in beta but not stable, and very little signs of movement.

    #![cfg(feature = "parallel")]
    trait ComponentBound = Component + Send + Sync;
    #![cfg(not(feature = "parallel"))]
    trait ComponentBound = Component;
  • Duplicate code: Copy code per feature = "parallel" and not(feature = "parallel"). Simple but ugly.

  • Poor man's trait aliases: Implemented in e1477cf, but not ideal, because users have to specify the type of world in their closures: 1ed2912, which is very badTM.

  • Macro to generate per feature fn (current state): Kind of like the duplication option without the duplication, but macro is ugly to maintain.

@chinedufn @WaDelma I think it's good to have both of you review this (again). The summary above should capture the options I've tried.

Copy link
Contributor Author

@chinedufn chinedufn left a comment

Choose a reason for hiding this comment

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

Looks great - thanks for making this much more robust than what I originally had!

src/world/lazy.rs Show resolved Hide resolved
}

#[test]
fn non_send_component_is_accepted() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@azriel91
Copy link
Member

Just realized that's no test for a storage that isn't Send, if you like, could you add one? That'll help the PR get through a little faster.

@chinedufn
Copy link
Contributor Author

If the type = VecStorage<Self> and Self isn't send then isn't the storage non send?

Or am I missing something here?

@azriel91
Copy link
Member

ah that's correct ✌️ -- it backs onto Vec which only impls Send when T is Send

Copy link
Member

@WaDelma WaDelma left a comment

Choose a reason for hiding this comment

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

LGTM

@azriel91
Copy link
Member

bors r+

bors bot added a commit that referenced this pull request Feb 12, 2020
674: Remove send+sync requirement if not parallel r=azriel91 a=chinedufn

Closes #673 

Co-authored-by: Chinedu Francis Nwafili <[email protected]>
Co-authored-by: Azriel Hoh <[email protected]>
@bors
Copy link
Contributor

bors bot commented Feb 12, 2020

Build succeeded

@bors bors bot merged commit da350ee into amethyst:master Feb 12, 2020
@chinedufn chinedufn deleted the non-send-sync-resources branch February 13, 2020 00:08
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.

Components require Send + Sync even when parallel feature is disabled
3 participants