From 93dcf434b1402f33f175f2a7c6eeaeb8f68dc005 Mon Sep 17 00:00:00 2001 From: Imbris Date: Wed, 1 May 2019 08:59:23 -0400 Subject: [PATCH 1/3] point to latest asset commit Former-commit-id: 844f4c00d09b19ae3870565bb88fe184c6e8cccf --- assets/voxygen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/voxygen b/assets/voxygen index cff10b010d..7ebb1a9205 160000 --- a/assets/voxygen +++ b/assets/voxygen @@ -1 +1 @@ -Subproject commit cff10b010db25ce9af5edbdfb5ef0af889dd741a +Subproject commit 7ebb1a92057e6c0b9d989ffb7a5fe321599ddd6e From f0b0b83cc8501973fd99963f0025f41f17e38658 Mon Sep 17 00:00:00 2001 From: Imbris Date: Wed, 1 May 2019 14:10:43 -0400 Subject: [PATCH 2/3] Store thread pool in State, Remove unnecessary dep Former-commit-id: cbce09915267f264801c174817b97ed3528715fd --- Cargo.lock | 2 +- assets/voxygen | 2 +- common/Cargo.toml | 2 +- common/src/state.rs | 11 ++++++++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3e40057f2e..e572ded28b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2289,9 +2289,9 @@ dependencies = [ "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "shred 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "specs 0.14.3 (registry+https://github.com/rust-lang/crates.io-index)", "sphynx 0.1.0 (git+https://gitlab.com/veloren/sphynx.git)", "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/assets/voxygen b/assets/voxygen index cff10b010d..7ebb1a9205 160000 --- a/assets/voxygen +++ b/assets/voxygen @@ -1 +1 @@ -Subproject commit cff10b010db25ce9af5edbdfb5ef0af889dd741a +Subproject commit 7ebb1a92057e6c0b9d989ffb7a5fe321599ddd6e diff --git a/common/Cargo.toml b/common/Cargo.toml index da924061fd..30ca746a79 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -8,7 +8,6 @@ edition = "2018" sphynx = { git = "https://gitlab.com/veloren/sphynx.git", features = ["serde1"] } specs = { version = "0.14", features = ["serde"] } -shred = { version = "0.7", features = ["nightly"] } vek = { version = "0.9", features = ["serde"] } dot_vox = "4.0" threadpool = "1.7" @@ -19,3 +18,4 @@ serde_derive = "1.0" bincode = "1.0" log = "0.4" rand = "0.5" +rayon = "1.0" diff --git a/common/src/state.rs b/common/src/state.rs index 9e7646a988..447c9117e4 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -7,14 +7,15 @@ use crate::{ sys, terrain::{TerrainChunk, TerrainMap}, }; -use shred::{Fetch, FetchMut}; +use rayon::{ThreadPool, ThreadPoolBuilder}; use specs::{ saveload::{MarkedBuilder, MarkerAllocator}, + shred::{Fetch, FetchMut}, storage::{MaskedStorage as EcsMaskedStorage, Storage as EcsStorage}, Builder, Component, DispatcherBuilder, Entity as EcsEntity, EntityBuilder as EcsEntityBuilder, }; use sphynx; -use std::{collections::HashSet, time::Duration}; +use std::{collections::HashSet, sync::Arc, time::Duration}; use vek::*; /// How much faster should an in-game day be compared to a real day? @@ -57,6 +58,8 @@ impl Changes { /// things like entity components, terrain data, and global state like weather, time of day, etc. pub struct State { ecs: sphynx::World, + // Avoid lifetime annotation by storing a thread pool instead of the whole dispatcher + thread_pool: Arc, changes: Changes, } @@ -65,6 +68,7 @@ impl State { pub fn new() -> Self { Self { ecs: sphynx::World::new(specs::World::new(), Self::setup_sphynx_world), + thread_pool: Arc::new(ThreadPoolBuilder::new().build().unwrap()), changes: Changes::default(), } } @@ -77,6 +81,7 @@ impl State { Self::setup_sphynx_world, state_package, ), + thread_pool: Arc::new(ThreadPoolBuilder::new().build().unwrap()), changes: Changes::default(), } } @@ -197,7 +202,7 @@ impl State { self.ecs.write_resource::().0 = dt.as_secs_f64(); // Create and run dispatcher for ecs systems - let mut dispatch_builder = DispatcherBuilder::new(); + let mut dispatch_builder = DispatcherBuilder::new().with_pool(self.thread_pool.clone()); sys::add_local_systems(&mut dispatch_builder); // This dispatches all the systems in parallel dispatch_builder.build().dispatch(&self.ecs.res); From 7a192a9466c95d5d3b08c1f78480a482cbc8ee07 Mon Sep 17 00:00:00 2001 From: Imbris Date: Wed, 1 May 2019 14:46:06 -0400 Subject: [PATCH 3/3] add nightly feature back for specs -> shred Former-commit-id: b483f75c10cc47faa66ab8063f7747e654068634 --- common/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/Cargo.toml b/common/Cargo.toml index 30ca746a79..7c6a403538 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] sphynx = { git = "https://gitlab.com/veloren/sphynx.git", features = ["serde1"] } -specs = { version = "0.14", features = ["serde"] } +specs = { version = "0.14", features = ["serde", "nightly"] } vek = { version = "0.9", features = ["serde"] } dot_vox = "4.0" threadpool = "1.7"