Skip to content

Commit 24fff2e

Browse files
feat: use single threaded flecs (#883)
1 parent d817614 commit 24fff2e

File tree

14 files changed

+47
-66
lines changed

14 files changed

+47
-66
lines changed

crates/hyperion/src/egress/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ impl Module for EgressModule {
6060
&Compose($),
6161
&mut Blocks($),
6262
)
63-
.multi_threaded()
6463
.kind::<flecs::pipeline::OnUpdate>()
6564
.each_iter(move |it: TableIter<'_, false>, _, (compose, mc)| {
6665
let span = info_span!("broadcast_chunk_deltas");

crates/hyperion/src/egress/sync_chunks.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ impl Module for SyncChunksModule {
4545
)
4646
.with_enum(PacketState::Play)
4747
.kind::<flecs::pipeline::OnUpdate>()
48-
.multi_threaded()
4948
.each_iter(
5049
move |it, _, (compose, last_sent, pose, &stream_id, chunk_changes)| {
5150
let system = it.system();
@@ -161,7 +160,7 @@ impl Module for SyncChunksModule {
161160
system!("send_full_loaded_chunks", world, &Blocks($), &Compose($), &ConnectionId, &mut ChunkSendQueue)
162161
.with_enum(PacketState::Play)
163162
.kind::<flecs::pipeline::OnUpdate>()
164-
.multi_threaded()
163+
165164
.each_iter(
166165
move |it, _, (chunks, compose, &stream_id, queue)| {
167166
const MAX_CHUNKS_PER_TICK: usize = 16;

crates/hyperion/src/egress/sync_entity_state.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ fn track_previous<T: ComponentId + Copy + Debug + PartialEq>(world: &World) {
5353

5454
world
5555
.system_named::<(&mut (Prev, T), &T)>(system_name.as_str())
56-
.multi_threaded()
5756
.kind_id(post_store)
5857
.each(|(prev, value)| {
5958
*prev = *value;
@@ -71,7 +70,6 @@ impl Module for EntityStateSyncModule {
7170
)>("entity_xp_sync")
7271
.term_at(0u32)
7372
.singleton()
74-
.multi_threaded()
7573
.kind::<flecs::pipeline::OnStore>()
7674
.each_iter(|table, idx, (compose, net, prev_xp, current)| {
7775
const {
@@ -99,7 +97,6 @@ impl Module for EntityStateSyncModule {
9997
});
10098

10199
system!("entity_metadata_sync", world, &Compose($), &mut MetadataChanges)
102-
.multi_threaded()
103100
.kind::<flecs::pipeline::OnStore>()
104101
.each_iter(move |it, row, (compose, metadata_changes)| {
105102
let system = it.system();
@@ -135,7 +132,6 @@ impl Module for EntityStateSyncModule {
135132
?&ConnectionId,
136133
&mut ActiveAnimation,
137134
)
138-
.multi_threaded()
139135
.kind::<flecs::pipeline::OnStore>()
140136
.each_iter(
141137
move |it, row, (position, compose, connection_id, animation)| {
@@ -177,7 +173,6 @@ impl Module for EntityStateSyncModule {
177173
&mut MovementTracking,
178174
&Flight,
179175
)
180-
.multi_threaded()
181176
.kind::<flecs::pipeline::PreStore>()
182177
.each_iter(
183178
|it,
@@ -368,7 +363,6 @@ impl Module for EntityStateSyncModule {
368363
&Owner,
369364
?&ConnectionId
370365
)
371-
.multi_threaded()
372366
.kind::<flecs::pipeline::OnUpdate>()
373367
.with_enum_wildcard::<EntityKind>()
374368
.each_iter(|it, row, (position, velocity, owner, connection_id)| {

crates/hyperion/src/ingress/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ impl Module for IngressModule {
345345
.system_named::<(&ReceiveState, &ConnectionId, &mut PacketDecoder)>("ingress_to_ecs")
346346
.term_at(0u32)
347347
.singleton() // StreamLookup
348-
// .multi_threaded()
349348
.immediate(true)
350349
.kind::<flecs::pipeline::PostLoad>()
351350
.each(move |(receive, connection_id, decoder)| {
@@ -445,7 +444,6 @@ impl Module for IngressModule {
445444
&IgnMap($),
446445
)
447446
.kind::<flecs::pipeline::OnUpdate>()
448-
.multi_threaded()
449447
.each_iter(
450448
move |it,
451449
row,

crates/hyperion/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#![feature(pointer_is_aligned_to)]
2626
#![feature(thread_local)]
2727

28-
pub const NUM_THREADS: usize = 8;
28+
pub const NUM_THREADS: usize = 1;
2929
pub const CHUNK_HEIGHT_SPAN: u32 = 384; // 512; // usually 384
3030

3131
use std::{

crates/hyperion/src/simulation/inventory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl Module for InventoryModule {
123123
?&OpenInventory,
124124
&ConnectionId,
125125
)
126-
.multi_threaded()
126+
127127
.kind::<flecs_ecs::prelude::flecs::pipeline::OnStore>()
128128
.each_iter(
129129
|

crates/hyperion/src/simulation/metadata/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ where
4545
&mut T, // (1)
4646
&mut MetadataChanges, // (2)
4747
)>(system_name)
48-
.multi_threaded()
4948
.kind::<flecs::pipeline::OnUpdate>()
5049
.each(|(prev, current, metadata_changes)| {
5150
if prev != current {

events/tag/src/module/attack.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ impl Module for AttackModule {
104104
&ConnectionId,
105105
)
106106
.with_enum(PacketState::Play)
107-
.multi_threaded()
108107
.kind::<flecs::pipeline::OnUpdate>()
109108
.each_iter(move |it, _, (compose, kill_count, stream)| {
110109
const MAX_KILLS: usize = 10;
@@ -132,7 +131,7 @@ impl Module for AttackModule {
132131

133132
// TODO: This code should be split between melee attacks and bow attacks
134133
system!("handle_attacks", world, &mut EventQueue<event::AttackEntity>($), &Compose($))
135-
.multi_threaded()
134+
136135
.each_iter(
137136
move |it: TableIter<'_, false>,
138137
_,

events/tag/src/module/block.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl Module for BlockModule {
7373

7474
system!("handle_pending_air", world, &mut PendingDestruction($), &mut Blocks($), &Compose($))
7575
.write::<PlayerInventory>()
76-
.multi_threaded()
76+
7777
.each_iter(
7878
move |it: TableIter<'_, false>,
7979
_,
@@ -155,7 +155,7 @@ impl Module for BlockModule {
155155
);
156156

157157
system!("handle_destroyed_blocks", world, &mut Blocks($), &mut EventQueue<event::DestroyBlock>($), &Compose($), &OreVeins($))
158-
.multi_threaded()
158+
159159
.each_iter(move |it: TableIter<'_, false>, _, (blocks, event_queue, compose, ore_veins): (&mut Blocks, &mut EventQueue<event::DestroyBlock>, &Compose, &OreVeins)| {
160160
let span = info_span!("handle_blocks");
161161
let _enter = span.enter();
@@ -303,7 +303,7 @@ impl Module for BlockModule {
303303
});
304304

305305
system!("handle_toggled_doors", world, &mut Blocks($), &mut EventQueue<event::ToggleDoor>($))
306-
.multi_threaded()
306+
307307
.each_iter(move |_it: TableIter<'_, false>, _, (mc, event_queue): (&mut Blocks, &mut EventQueue<event::ToggleDoor>)| {
308308
let span = info_span!("handle_toggled_doors");
309309
let _enter = span.enter();

events/tag/src/module/bow.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ impl Module for BowModule {
8585
&mut EventQueue<event::ItemInteract>,
8686
)
8787
.singleton()
88-
.multi_threaded()
8988
.kind::<flecs::pipeline::PostUpdate>()
9089
.each_iter(move |it, _, event_queue| {
9190
let _system = it.system();
@@ -203,7 +202,6 @@ impl Module for BowModule {
203202
&Compose($),
204203
&mut EventQueue<event::ProjectileEntityEvent>,
205204
)
206-
.multi_threaded()
207205
.singleton()
208206
.kind::<flecs::pipeline::PostUpdate>()
209207
.each_iter(move |it, _, (compose, event_queue)| {
@@ -263,7 +261,6 @@ impl Module for BowModule {
263261
world,
264262
&mut EventQueue<event::ProjectileBlockEvent>,
265263
)
266-
.multi_threaded()
267264
.kind::<flecs::pipeline::PreStore>()
268265
.each_iter(move |it, _, event_queue| {
269266
let _system = it.system();

0 commit comments

Comments
 (0)