Skip to content

Commit

Permalink
Switch from info to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
james7132 committed Jun 17, 2021
1 parent 77d3b6b commit 3c6bdc0
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 58 deletions.
40 changes: 20 additions & 20 deletions backroll/src/backend/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use async_channel::TryRecvError;
use parking_lot::RwLock;
use std::sync::Arc;
use std::time::Duration;
use tracing::{debug, info};
use tracing::debug;

const RECOMMENDATION_INTERVAL: Frame = 240;
const DEFAULT_FRAME_DELAY: Frame = 3;
Expand Down Expand Up @@ -255,7 +255,7 @@ impl<T: Config> P2PSessionRef<T> {
// of the game. All other players need to be disconnected.
// that if the endpoint is not initalized, this must be the local player.
let current_frame = self.sync.frame_count();
info!(
debug!(
"Disconnecting local player {} at frame {} by user request.",
queue, last_frame
);
Expand All @@ -265,7 +265,7 @@ impl<T: Config> P2PSessionRef<T> {
}
}
} else {
info!(
debug!(
"Disconnecting queue {} at frame {} by user request.",
queue, last_frame
);
Expand All @@ -279,7 +279,7 @@ impl<T: Config> P2PSessionRef<T> {

self.players[queue].disconnect();

info!("Changing queue {} local connect status for last frame from {} to {} on disconnect request (current: {}).",
debug!("Changing queue {} local connect status for last frame from {} to {} on disconnect request (current: {}).",
queue, self.local_connect_status[queue].read().last_frame, syncto, frame_count);

{
Expand All @@ -289,12 +289,12 @@ impl<T: Config> P2PSessionRef<T> {
}

if syncto < frame_count {
info!(
debug!(
"Adjusting simulation to account for the fact that {} disconnected @ {}.",
queue, syncto
);
self.sync.adjust_simulation(commands, syncto);
info!("Finished adjusting simulation.");
debug!("Finished adjusting simulation.");
}

commands.push(Command::Event(Event::Disconnected(PlayerHandle(queue))));
Expand Down Expand Up @@ -421,10 +421,10 @@ impl<T: Config> P2PSessionRef<T> {
self.poll_n_players(commands)
};

info!("last confirmed frame in p2p backend is {}.", min_frame);
debug!("last confirmed frame in p2p backend is {}.", min_frame);
if min_frame >= 0 {
debug_assert!(min_frame != Frame::MAX);
info!("setting confirmed frame in sync to {}.", min_frame);
debug!("setting confirmed frame in sync to {}.", min_frame);
self.sync.set_last_confirmed_frame(min_frame);
}

Expand Down Expand Up @@ -458,15 +458,15 @@ impl<T: Config> P2PSessionRef<T> {
if !local_status.disconnected {
min_frame = std::cmp::min(local_status.last_frame, min_frame);
}
info!(
debug!(
"local endp: connected = {}, last_received = {}, total_min_confirmed = {}.",
!local_status.disconnected, local_status.last_frame, min_frame
);
if !queue_connected && !local_status.disconnected {
info!("disconnecting player {} by remote request.", i);
debug!("disconnecting player {} by remote request.", i);
self.disconnect_player_queue(commands, i, min_frame);
}
info!("min_frame = {}.", min_frame);
debug!("min_frame = {}.", min_frame);
}
min_frame
}
Expand All @@ -477,7 +477,7 @@ impl<T: Config> P2PSessionRef<T> {
for queue in 0..self.players.len() {
let mut queue_connected = true;
let mut queue_min_confirmed = Frame::MAX;
info!("considering queue {}.", queue);
debug!("considering queue {}.", queue);
for (i, player) in self.players.iter().enumerate() {
// we're going to do a lot of logic here in consideration of endpoint i.
// keep accumulating the minimum confirmed point for all n*n packets and
Expand All @@ -487,10 +487,10 @@ impl<T: Config> P2PSessionRef<T> {
let status = peer.get_peer_connect_status(queue);
queue_connected = queue_connected && !status.disconnected;
queue_min_confirmed = std::cmp::min(status.last_frame, queue_min_confirmed);
info!("endpoint {}: connected = {}, last_received = {}, queue_min_confirmed = {}.",
debug!("endpoint {}: connected = {}, last_received = {}, queue_min_confirmed = {}.",
i, queue_connected, status.last_frame, queue_min_confirmed);
} else {
info!("endpoint {}: ignoring... not running.", i);
debug!("endpoint {}: ignoring... not running.", i);
}
}

Expand All @@ -499,7 +499,7 @@ impl<T: Config> P2PSessionRef<T> {
if !local_status.disconnected {
queue_min_confirmed = std::cmp::min(local_status.last_frame, queue_min_confirmed);
}
info!(
debug!(
"local endp: connected = {}, last_received = {}, queue_min_confirmed = {}.",
!local_status.disconnected, local_status.last_frame, queue_min_confirmed
);
Expand All @@ -511,11 +511,11 @@ impl<T: Config> P2PSessionRef<T> {
// so, we need to re-adjust. This can happen when we detect our own disconnect at frame n
// and later receive a disconnect notification for frame n-1.
if !local_status.disconnected || local_status.last_frame > queue_min_confirmed {
info!("disconnecting queue {} by remote request.", queue);
debug!("disconnecting queue {} by remote request.", queue);
self.disconnect_player_queue(commands, queue, queue_min_confirmed);
}
}
info!("min_frame = {}.", min_frame);
debug!("min_frame = {}.", min_frame);
}
min_frame
}
Expand Down Expand Up @@ -715,7 +715,7 @@ impl<T: Config> P2PSession<T> {
pub fn advance_frame(&self) -> Commands<T> {
let mut session_ref = self.0.write();
let mut commands = Commands::<T>::default();
info!("End of frame ({})...", session_ref.sync.frame_count());
debug!("End of frame ({})...", session_ref.sync.frame_count());
if !session_ref.synchronizing {
session_ref.sync.increment_frame(&mut commands);
}
Expand Down Expand Up @@ -760,7 +760,7 @@ impl<T: Config> P2PSession<T> {
// of the game. All other players need to be disconnected.
// that if the endpoint is not initalized, this must be the local player.
let current_frame = session_ref.sync.frame_count();
info!(
debug!(
"Disconnecting local player {} at frame {} by user request.",
queue, last_frame
);
Expand All @@ -770,7 +770,7 @@ impl<T: Config> P2PSession<T> {
}
}
} else {
info!(
debug!(
"Disconnecting queue {} at frame {} by user request.",
queue, last_frame
);
Expand Down
4 changes: 2 additions & 2 deletions backroll/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
collections::hash_map::DefaultHasher,
hash::{Hash, Hasher},
};
use tracing::{error, info};
use tracing::{debug, error};

/// A singular command for a Backroll session client to execute.
///
Expand Down Expand Up @@ -85,7 +85,7 @@ impl<T: Config> SaveState<T> {
}

fn save_state(self, state: T::State, checksum: Option<u64>) {
info!(
debug!(
"=== Saved frame state {} (checksum: {:08x}).",
self.frame,
checksum.unwrap_or(0)
Expand Down
36 changes: 18 additions & 18 deletions backroll/src/input.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{BackrollError, Config, Frame, PlayerHandle, MAX_PLAYERS, MAX_ROLLBACK_FRAMES};
use std::convert::TryFrom;
use tracing::info;
use tracing::debug;

#[inline]
fn previous_frame(offset: usize) -> usize {
Expand Down Expand Up @@ -150,7 +150,7 @@ impl<T: Config> InputQueue<T> {
}

pub fn last_confirmed_frame(&self) -> Frame {
info!("returning last confirmed frame {}.", self.last_added_frame);
debug!("returning last confirmed frame {}.", self.last_added_frame);
self.last_added_frame
}

Expand All @@ -169,7 +169,7 @@ impl<T: Config> InputQueue<T> {
frame = std::cmp::min(frame, self.last_frame_requested)
}

info!(
debug!(
"discarding confirmed frames up to {} (last_added:{} length:{}).",
frame, self.last_added_frame, self.length
);
Expand All @@ -180,7 +180,7 @@ impl<T: Config> InputQueue<T> {
let offset = frame - self.inputs[self.tail].frame + 1;
let offset = usize::try_from(offset).unwrap();

info!("difference of {} frames.", offset);
debug!("difference of {} frames.", offset);

self.tail = (self.tail + offset) % MAX_ROLLBACK_FRAMES;
self.length -= offset;
Expand All @@ -192,7 +192,7 @@ impl<T: Config> InputQueue<T> {
super::is_null(self.first_incorrect_frame) || frame <= self.first_incorrect_frame
);

info!("resetting all prediction errors back to frame {}.", frame);
debug!("resetting all prediction errors back to frame {}.", frame);

// There's nothing really to do other than reset our prediction
// state and the incorrect frame counter...
Expand All @@ -210,7 +210,7 @@ impl<T: Config> InputQueue<T> {
}

pub fn get_input(&mut self, frame: Frame) -> FetchedInput<T::Input> {
info!("requesting input frame {:?}.", frame);
debug!("requesting input frame {:?}.", frame);

// No one should ever try to grab any input when we have a prediction
// error. Doing so means that we're just going further down the wrong
Expand All @@ -231,21 +231,21 @@ impl<T: Config> InputQueue<T> {
offset = (offset + self.tail) % MAX_ROLLBACK_FRAMES;
let input = self.inputs[offset].clone();
debug_assert!(input.frame == frame);
info!("returning confirmed frame number {}.", input.frame);
debug!("returning confirmed frame number {}.", input.frame);
return FetchedInput::Normal(input);
}

// The requested frame isn't in the queue. Bummer. This means we need
// to return a prediction frame. Predict that the user will do the
// same thing they did last time.
if frame == 0 {
info!("basing new prediction frame from nothing, you're client wants frame 0.");
debug!("basing new prediction frame from nothing, you're client wants frame 0.");
self.prediction.clear();
} else if super::is_null(self.last_added_frame) {
info!("basing new prediction frame from nothing, since we have no frames yet.");
debug!("basing new prediction frame from nothing, since we have no frames yet.");
self.prediction.clear();
} else {
info!(
debug!(
"basing new prediction frame from previously added frame (frame: {}).",
self.inputs[previous_frame(self.head)].frame
);
Expand All @@ -259,7 +259,7 @@ impl<T: Config> InputQueue<T> {
// frame number requested by the client, though.
let mut prediction = self.prediction.clone();
prediction.frame = frame;
info!(
debug!(
"returning prediction frame number {} ({}).",
frame, self.prediction.frame
);
Expand All @@ -274,7 +274,7 @@ impl<T: Config> InputQueue<T> {
|| input.frame == self.last_user_added_frame + 1
);
self.last_user_added_frame = input.frame;
info!("adding input frame number {} to queue.", input.frame);
debug!("adding input frame number {} to queue.", input.frame);

// Move the queue head to the correct point in preparation to
// input the frame into the queue.
Expand All @@ -289,7 +289,7 @@ impl<T: Config> InputQueue<T> {
}

fn add_delayed_input(&mut self, frame: Frame, input: FrameInput<T::Input>) {
info!("adding delayed input frame number {} to queue.", frame);
debug!("adding delayed input frame number {} to queue.", frame);
debug_assert!(super::is_null(self.last_added_frame) || frame == self.last_added_frame + 1);
debug_assert!(frame == 0 || self.inputs[previous_frame(self.head)].frame == frame - 1);

Expand All @@ -308,7 +308,7 @@ impl<T: Config> InputQueue<T> {
// remember the first input which was incorrect so we can report it
// in first_incorrect_frame()
if super::is_null(self.first_incorrect_frame) && self.prediction != input {
info!("frame {} does not match prediction. marking error.", frame);
debug!("frame {} does not match prediction. marking error.", frame);
self.first_incorrect_frame = frame;
}

Expand All @@ -319,7 +319,7 @@ impl<T: Config> InputQueue<T> {
if self.prediction.frame == self.last_frame_requested
&& super::is_null(self.first_incorrect_frame)
{
info!("prediction is correct! dumping out of prediction mode.");
debug!("prediction is correct! dumping out of prediction mode.");
self.prediction.frame = super::NULL_FRAME;
} else {
self.prediction.frame += 1;
Expand All @@ -329,7 +329,7 @@ impl<T: Config> InputQueue<T> {
}

fn advance_queue_head(&mut self, mut frame: Frame) -> Frame {
info!("advancing queue head to frame {}.", frame);
debug!("advancing queue head to frame {}.", frame);
let mut expected_frame = if self.first_frame {
0
} else {
Expand All @@ -341,7 +341,7 @@ impl<T: Config> InputQueue<T> {
// This can occur when the frame delay has dropped since the last
// time we shoved a frame into the system. In this case, there's
// no room on the queue. Toss it.
info!(
debug!(
"Dropping input frame {} (expected next frame to be {}).",
frame, expected_frame
);
Expand All @@ -353,7 +353,7 @@ impl<T: Config> InputQueue<T> {
// time we shoved a frame into the system. We need to replicate the
// last frame in the queue several times in order to fill the space
// left.
info!(
debug!(
"Adding padding frame {} to account for change in frame delay.",
expected_frame
);
Expand Down
Loading

0 comments on commit 3c6bdc0

Please sign in to comment.