I am trying to develop a fast pace networked action game. I've read some articles and tutorial on the subject, and I've come across a problem in my implementation.
I've successfully implemented client side prediction, but I've run into a performance issue.
Both my server and my clients maintain a circular buffer of previous gamestates.
The server has this buffer so it can replay client input that are received late because of lag.
The client has this buffer so it can replay it's input (the ones that have not yet been acknowledged).
Now here comes the performance issue : I am coding in C#, and the way I went about implementing my circular buffer is this:
Each GameState is store into a LinkedList. The first item in the LinkedList is the most recent, the last is the older.
When I need to replay part of my circular buffer, I do it like this :
1) I clone the last GameState.
2) I store the clone into Last.Previous
3) I update Last.Previous
This "works", the client side prediction works flawlessly, my simulation is deterministic, and I the entity I control never "snaps".
However, with all the cloning going on, the c# garbage collector is on it's knees, and it's starting to show!
Is there a best practice (more efficient than what I am doing currently) to implement a circular buffer of past gamestates, and replaying them?