From aee0eca6d6baa97ade171c7f620cebcb18fc1572 Mon Sep 17 00:00:00 2001 From: DimitriTimoz Date: Mon, 25 Dec 2023 17:45:45 +0100 Subject: [PATCH] Remove some tracing --- minecraft-server/src/entities/entity.rs | 2 -- minecraft-server/src/main.rs | 4 ++-- minecraft-server/src/player_handler/login.rs | 3 +-- minecraft-server/src/player_handler/network.rs | 6 +++--- minecraft-server/src/player_handler/status.rs | 2 +- minecraft-server/src/world/ecs.rs | 14 ++------------ 6 files changed, 9 insertions(+), 22 deletions(-) diff --git a/minecraft-server/src/entities/entity.rs b/minecraft-server/src/entities/entity.rs index 5ba61cb2..606a1cbd 100644 --- a/minecraft-server/src/entities/entity.rs +++ b/minecraft-server/src/entities/entity.rs @@ -31,8 +31,6 @@ pub struct Entity { } impl Handler { - #[cfg_attr(feature = "tracing", instrument(skip_all))] - pub async fn init(self, server_msg_rcvr: BroadcastReceiver) { self.insert_task("newton", tokio::spawn(newton_task(self.clone(), server_msg_rcvr))).await; } diff --git a/minecraft-server/src/main.rs b/minecraft-server/src/main.rs index d0f414d7..5c3a3fc3 100644 --- a/minecraft-server/src/main.rs +++ b/minecraft-server/src/main.rs @@ -23,7 +23,7 @@ impl std::future::Future for ServerFuture { #[tokio::main] async fn main() { - #[cfg(feature = "tracing")] + #[cfg(feature = "trace")] #[global_allocator] static GLOBAL: tracy_client::ProfiledAllocator = tracy_client::ProfiledAllocator::new(std::alloc::System, 100); @@ -32,7 +32,7 @@ async fn main() { let subscriber = Registry::default() .with(fmt::layer()); - #[cfg(feature = "tracing")] + #[cfg(feature = "trace")] let subscriber = subscriber .with(tracing_tracy::TracyLayer::new()); diff --git a/minecraft-server/src/player_handler/login.rs b/minecraft-server/src/player_handler/login.rs index f794cc6e..60ca9ba1 100644 --- a/minecraft-server/src/player_handler/login.rs +++ b/minecraft-server/src/player_handler/login.rs @@ -6,8 +6,7 @@ pub struct LoggedInPlayerInfo { pub(super) uuid: u128, } -#[cfg_attr(feature = "tracing", instrument(skip_all))] - +#[cfg_attr(feature = "trace", instrument(skip_all))] pub async fn login(stream: &mut TcpStream, addr: SocketAddr) -> Result { // Receive login start let packet = receive_packet(stream).await?; diff --git a/minecraft-server/src/player_handler/network.rs b/minecraft-server/src/player_handler/network.rs index 8c2b90aa..d3a86317 100644 --- a/minecraft-server/src/player_handler/network.rs +++ b/minecraft-server/src/player_handler/network.rs @@ -48,7 +48,7 @@ pub async fn receive_packet_split(stream: &mut OwnedReadHalf) -> Result, Ok(data) } -#[cfg_attr(feature = "tracing", instrument)] +#[cfg_attr(feature = "trace", instrument)] pub async fn send_packet_raw(stream: &mut TcpStream, packet: &[u8]) { let length = VarInt::from(packet.len()); stream.write_all(length.serialize_minecraft_packet().unwrap().as_slice()).await.unwrap(); @@ -56,7 +56,7 @@ pub async fn send_packet_raw(stream: &mut TcpStream, packet: &[u8]) { stream.flush().await.unwrap(); } -#[cfg_attr(feature = "tracing", instrument)] +#[cfg_attr(feature = "trace", instrument)] pub async fn send_packet_raw_split(stream: &mut OwnedWriteHalf, packet: &[u8]) { let length = VarInt::from(packet.len()); stream.write_all(length.serialize_minecraft_packet().unwrap().as_slice()).await.unwrap(); @@ -64,7 +64,7 @@ pub async fn send_packet_raw_split(stream: &mut OwnedWriteHalf, packet: &[u8]) { stream.flush().await.unwrap(); } -#[cfg_attr(feature = "tracing", instrument(skip_all))] +#[cfg_attr(feature = "trace", instrument(skip_all))] pub async fn send_packet<'a, P: MinecraftPacketPart<'a>>(stream: &mut TcpStream, packet: P) { let packet = packet.serialize_minecraft_packet().unwrap(); send_packet_raw(stream, packet.as_slice()).await; diff --git a/minecraft-server/src/player_handler/status.rs b/minecraft-server/src/player_handler/status.rs index 0999565b..7237089c 100644 --- a/minecraft-server/src/player_handler/status.rs +++ b/minecraft-server/src/player_handler/status.rs @@ -1,6 +1,6 @@ use super::*; -#[cfg_attr(feature = "tracing", instrument(skip_all))] +#[cfg_attr(feature = "trace", instrument(skip_all))] pub async fn status(stream: &mut TcpStream) -> Result<(), ()> { loop { let packet = receive_packet(stream).await?; diff --git a/minecraft-server/src/world/ecs.rs b/minecraft-server/src/world/ecs.rs index 265eee7c..b07f217e 100644 --- a/minecraft-server/src/world/ecs.rs +++ b/minecraft-server/src/world/ecs.rs @@ -31,16 +31,12 @@ impl Entities { } /// Observe an entity through a closure - #[cfg_attr(feature = "tracing", instrument(skip_all))] - pub(super) async fn observe_entity(&self, eid: Eid, observer: impl FnOnce(&AnyEntity) -> R) -> Option { self.entities.read().await.get(&eid).map(observer) } /// Observe entities in a chunk through a closure /// That closure will be applied to each entity, and the results will be returned in a vector - #[cfg_attr(feature = "tracing", instrument(skip_all))] - pub(super) async fn observe_entities(&self, chunk: ChunkColumnPosition, mut observer: impl FnMut(&AnyEntity) -> Option) -> Vec { let entities = self.entities.read().await; let chunks = self.chunks.read().await; @@ -57,8 +53,6 @@ impl Entities { } /// Mutate an entity through a closure - #[cfg_attr(feature = "tracing", instrument(skip_all))] - pub(super) async fn mutate_entity(&self, eid: Eid, mutator: impl FnOnce(&mut AnyEntity) -> (R, EntityChanges)) -> Option<(R, EntityChanges)> { let mut entities = self.entities.write().await; @@ -79,8 +73,7 @@ impl Entities { } } - #[cfg_attr(feature = "tracing", instrument(skip_all))] - + #[cfg_attr(feature = "trace", instrument(skip_all))] pub(super) async fn spawn_entity(&self, entity: AnyEntity, world: &'static World, receiver: BroadcastReceiver) -> (Eid, UUID) where AnyEntity: TryAsEntityRef, Handler: EntityExt { @@ -100,8 +93,6 @@ impl Entities { (eid, uuid) } - #[cfg_attr(feature = "tracing", instrument(skip_all))] - pub(super) async fn insert_entity_task(&self, eid: Eid, name: &'static str, handle: EntityTaskHandle) { let mut entity_tasks = self.entity_tasks.write().await; let old = entity_tasks.entry(eid).or_insert(HashMap::new()).insert(name, handle); @@ -111,8 +102,7 @@ impl Entities { } /// Remove an entity - #[cfg_attr(feature = "tracing", instrument(skip_all))] - + #[cfg_attr(feature = "trace", instrument(skip_all))] pub(super) async fn remove_entity(&self, eid: Eid) -> Option { let entity = self.entities.write().await.remove(&eid); let mut chunks = self.chunks.write().await;