Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/hyperion/src/egress/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ impl Module for EgressModule {
&Compose($),
&mut Blocks($),
)
.multi_threaded()
.kind::<flecs::pipeline::OnUpdate>()
.each_iter(move |it: TableIter<'_, false>, _, (compose, mc)| {
let span = info_span!("broadcast_chunk_deltas");
Expand Down
3 changes: 1 addition & 2 deletions crates/hyperion/src/egress/sync_chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ impl Module for SyncChunksModule {
)
.with_enum(PacketState::Play)
.kind::<flecs::pipeline::OnUpdate>()
.multi_threaded()
.each_iter(
move |it, _, (compose, last_sent, pose, &stream_id, chunk_changes)| {
let system = it.system();
Expand Down Expand Up @@ -161,7 +160,7 @@ impl Module for SyncChunksModule {
system!("send_full_loaded_chunks", world, &Blocks($), &Compose($), &ConnectionId, &mut ChunkSendQueue)
.with_enum(PacketState::Play)
.kind::<flecs::pipeline::OnUpdate>()
.multi_threaded()

.each_iter(
move |it, _, (chunks, compose, &stream_id, queue)| {
const MAX_CHUNKS_PER_TICK: usize = 16;
Expand Down
6 changes: 0 additions & 6 deletions crates/hyperion/src/egress/sync_entity_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ fn track_previous<T: ComponentId + Copy + Debug + PartialEq>(world: &World) {

world
.system_named::<(&mut (Prev, T), &T)>(system_name.as_str())
.multi_threaded()
.kind_id(post_store)
.each(|(prev, value)| {
*prev = *value;
Expand All @@ -71,7 +70,6 @@ impl Module for EntityStateSyncModule {
)>("entity_xp_sync")
.term_at(0u32)
.singleton()
.multi_threaded()
.kind::<flecs::pipeline::OnStore>()
.each_iter(|table, idx, (compose, net, prev_xp, current)| {
const {
Expand Down Expand Up @@ -99,7 +97,6 @@ impl Module for EntityStateSyncModule {
});

system!("entity_metadata_sync", world, &Compose($), &mut MetadataChanges)
.multi_threaded()
.kind::<flecs::pipeline::OnStore>()
.each_iter(move |it, row, (compose, metadata_changes)| {
let system = it.system();
Expand Down Expand Up @@ -135,7 +132,6 @@ impl Module for EntityStateSyncModule {
?&ConnectionId,
&mut ActiveAnimation,
)
.multi_threaded()
.kind::<flecs::pipeline::OnStore>()
.each_iter(
move |it, row, (position, compose, connection_id, animation)| {
Expand Down Expand Up @@ -177,7 +173,6 @@ impl Module for EntityStateSyncModule {
&mut MovementTracking,
&Flight,
)
.multi_threaded()
.kind::<flecs::pipeline::PreStore>()
.each_iter(
|it,
Expand Down Expand Up @@ -368,7 +363,6 @@ impl Module for EntityStateSyncModule {
&Owner,
?&ConnectionId
)
.multi_threaded()
.kind::<flecs::pipeline::OnUpdate>()
.with_enum_wildcard::<EntityKind>()
.each_iter(|it, row, (position, velocity, owner, connection_id)| {
Expand Down
2 changes: 0 additions & 2 deletions crates/hyperion/src/ingress/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ impl Module for IngressModule {
.system_named::<(&ReceiveState, &ConnectionId, &mut PacketDecoder)>("ingress_to_ecs")
.term_at(0u32)
.singleton() // StreamLookup
// .multi_threaded()
.immediate(true)
.kind::<flecs::pipeline::PostLoad>()
.each(move |(receive, connection_id, decoder)| {
Expand Down Expand Up @@ -445,7 +444,6 @@ impl Module for IngressModule {
&IgnMap($),
)
.kind::<flecs::pipeline::OnUpdate>()
.multi_threaded()
.each_iter(
move |it,
row,
Expand Down
2 changes: 1 addition & 1 deletion crates/hyperion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#![feature(pointer_is_aligned_to)]
#![feature(thread_local)]

pub const NUM_THREADS: usize = 8;
pub const NUM_THREADS: usize = 1;
pub const CHUNK_HEIGHT_SPAN: u32 = 384; // 512; // usually 384

use std::{
Expand Down
2 changes: 1 addition & 1 deletion crates/hyperion/src/simulation/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl Module for InventoryModule {
?&OpenInventory,
&ConnectionId,
)
.multi_threaded()

.kind::<flecs_ecs::prelude::flecs::pipeline::OnStore>()
.each_iter(
|
Expand Down
1 change: 0 additions & 1 deletion crates/hyperion/src/simulation/metadata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ where
&mut T, // (1)
&mut MetadataChanges, // (2)
)>(system_name)
.multi_threaded()
.kind::<flecs::pipeline::OnUpdate>()
.each(|(prev, current, metadata_changes)| {
if prev != current {
Expand Down
3 changes: 1 addition & 2 deletions events/tag/src/module/attack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ impl Module for AttackModule {
&ConnectionId,
)
.with_enum(PacketState::Play)
.multi_threaded()
.kind::<flecs::pipeline::OnUpdate>()
.each_iter(move |it, _, (compose, kill_count, stream)| {
const MAX_KILLS: usize = 10;
Expand Down Expand Up @@ -132,7 +131,7 @@ impl Module for AttackModule {

// TODO: This code should be split between melee attacks and bow attacks
system!("handle_attacks", world, &mut EventQueue<event::AttackEntity>($), &Compose($))
.multi_threaded()

.each_iter(
move |it: TableIter<'_, false>,
_,
Expand Down
6 changes: 3 additions & 3 deletions events/tag/src/module/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Module for BlockModule {

system!("handle_pending_air", world, &mut PendingDestruction($), &mut Blocks($), &Compose($))
.write::<PlayerInventory>()
.multi_threaded()

.each_iter(
move |it: TableIter<'_, false>,
_,
Expand Down Expand Up @@ -155,7 +155,7 @@ impl Module for BlockModule {
);

system!("handle_destroyed_blocks", world, &mut Blocks($), &mut EventQueue<event::DestroyBlock>($), &Compose($), &OreVeins($))
.multi_threaded()

.each_iter(move |it: TableIter<'_, false>, _, (blocks, event_queue, compose, ore_veins): (&mut Blocks, &mut EventQueue<event::DestroyBlock>, &Compose, &OreVeins)| {
let span = info_span!("handle_blocks");
let _enter = span.enter();
Expand Down Expand Up @@ -303,7 +303,7 @@ impl Module for BlockModule {
});

system!("handle_toggled_doors", world, &mut Blocks($), &mut EventQueue<event::ToggleDoor>($))
.multi_threaded()

.each_iter(move |_it: TableIter<'_, false>, _, (mc, event_queue): (&mut Blocks, &mut EventQueue<event::ToggleDoor>)| {
let span = info_span!("handle_toggled_doors");
let _enter = span.enter();
Expand Down
3 changes: 0 additions & 3 deletions events/tag/src/module/bow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ impl Module for BowModule {
&mut EventQueue<event::ItemInteract>,
)
.singleton()
.multi_threaded()
.kind::<flecs::pipeline::PostUpdate>()
.each_iter(move |it, _, event_queue| {
let _system = it.system();
Expand Down Expand Up @@ -203,7 +202,6 @@ impl Module for BowModule {
&Compose($),
&mut EventQueue<event::ProjectileEntityEvent>,
)
.multi_threaded()
.singleton()
.kind::<flecs::pipeline::PostUpdate>()
.each_iter(move |it, _, (compose, event_queue)| {
Expand Down Expand Up @@ -263,7 +261,6 @@ impl Module for BowModule {
world,
&mut EventQueue<event::ProjectileBlockEvent>,
)
.multi_threaded()
.kind::<flecs::pipeline::PreStore>()
.each_iter(move |it, _, event_queue| {
let _system = it.system();
Expand Down
2 changes: 1 addition & 1 deletion events/tag/src/module/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Module for ChatModule {
.add_trait::<(flecs::With, ChatCooldown)>();

system!("handle_chat_messages", world, &mut EventQueue<event::ChatMessage>($), &hyperion::net::Compose($))
.multi_threaded()

.each_iter(move |it: TableIter<'_, false>, _: usize, (event_queue, compose): (&mut EventQueue<event::ChatMessage>, &hyperion::net::Compose)| {
let world = it.world();
let span = info_span!("handle_chat_messages");
Expand Down
1 change: 0 additions & 1 deletion events/tag/src/module/regeneration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ impl Module for RegenerationModule {
&mut Health,
&Compose($)
)
.multi_threaded()
.tracing_each(
info_span!("regenerate"),
|(last_damaged, prev_health, health, compose)| {
Expand Down
80 changes: 39 additions & 41 deletions events/tag/src/module/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,44 @@ impl Module for StatsModule {
let mut tick_times = Vec::with_capacity(20 * 60); // 20 ticks per second, 60 seconds
let mut last_frame_time_total = 0.0;

system!("stats", world, &Compose($))
.multi_threaded()
.each_iter(move |it, _, compose| {
let span = info_span!("stats");
let _enter = span.enter();
let system = it.system();
let world = it.world();
let player_count = compose
.global()
.player_count
.load(std::sync::atomic::Ordering::Relaxed);

let info = world.info();
let current_frame_time_total = info.frame_time_total;

let ms_per_tick = (current_frame_time_total - last_frame_time_total) * 1000.0;
last_frame_time_total = current_frame_time_total;

tick_times.push(ms_per_tick);
if tick_times.len() > 20 * 60 {
tick_times.remove(0);
}

let avg_s05 = tick_times.iter().rev().take(20 * 5).sum::<f32>() / (20.0 * 5.0);
let avg_s15 = tick_times.iter().rev().take(20 * 15).sum::<f32>() / (20.0 * 15.0);
let avg_s60 = tick_times.iter().sum::<f32>() / tick_times.len() as f32;

let title = format!(
"§b{mode}§r\n§aµ/5s: {avg_s05:.2} ms §r| §eµ/15s: {avg_s15:.2} ms §r| §cµ/1m: \
{avg_s60:.2} ms"
);

let footer = format!("§d§l{player_count} players online");

let pkt = play::PlayerListHeaderS2c {
header: title.into_cow_text(),
footer: footer.into_cow_text(),
};

compose.broadcast(&pkt, system).send().unwrap();
});
system!("stats", world, &Compose($)).each_iter(move |it, _, compose| {
let span = info_span!("stats");
let _enter = span.enter();
let system = it.system();
let world = it.world();
let player_count = compose
.global()
.player_count
.load(std::sync::atomic::Ordering::Relaxed);

let info = world.info();
let current_frame_time_total = info.frame_time_total;

let ms_per_tick = (current_frame_time_total - last_frame_time_total) * 1000.0;
last_frame_time_total = current_frame_time_total;

tick_times.push(ms_per_tick);
if tick_times.len() > 20 * 60 {
tick_times.remove(0);
}

let avg_s05 = tick_times.iter().rev().take(20 * 5).sum::<f32>() / (20.0 * 5.0);
let avg_s15 = tick_times.iter().rev().take(20 * 15).sum::<f32>() / (20.0 * 15.0);
let avg_s60 = tick_times.iter().sum::<f32>() / tick_times.len() as f32;

let title = format!(
"§b{mode}§r\n§aµ/5s: {avg_s05:.2} ms §r| §eµ/15s: {avg_s15:.2} ms §r| §cµ/1m: \
{avg_s60:.2} ms"
);

let footer = format!("§d§l{player_count} players online");

let pkt = play::PlayerListHeaderS2c {
header: title.into_cow_text(),
footer: footer.into_cow_text(),
};

compose.broadcast(&pkt, system).send().unwrap();
});
}
}
1 change: 0 additions & 1 deletion events/tag/src/module/vanish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ impl Module for VanishModule {
&Vanished,
&Uuid,
)
.multi_threaded()
.kind::<flecs::pipeline::PreStore>()
.each_iter(move |it, row, (compose, _connection_id, vanished, uuid)| {
let entity = it.entity(row);
Expand Down
Loading