Measuring server frame time? [message #492071] |
Thu, 09 March 2017 15:19 |
iRANian
Messages: 4308 Registered: April 2011
Karma: 0
|
General (4 Stars) |
|
|
How would you go about measuring server frame time? Considering sfps is a shit measure for server lag.
Now for calculating server frame time recording pairing 'current frame number' and ('current time in milliseconds' - 'last time in milliseconds') ought to work right.
But how could I measure all the issues caused by Observers/Scripts and hooks and plugins? Do i need to use assembly hooking? I'd like to be able to record the lag caused by having all the extra script and logic running. I know I can modify the Dragonade source code for some of it, but there are also things I can't measure when just modifying the Dragonade source code.
I'm pretty sure Dragonade contains some slowdowns when the server is running for some time, for example on Rencorner you can see the sfps drop from 100 to 97 after server is running for a while. This causes infantry to suffer. It looks like just a 3 SFPS drop but it's averaged over a second so it's probably a very long pause.
Long time and well respected Renegade community member, programmer, modder and tester.
Scripts 4.0 private beta tester since May 2011.
My Renegade server plugins releases
[Updated on: Thu, 09 March 2017 15:32] Report message to a moderator
|
|
|
Re: Measuring server frame time? [message #492089 is a reply to message #492071] |
Wed, 15 March 2017 00:34 |
|
Gen_Blacky
Messages: 3250 Registered: September 2006
Karma: 1
|
General (3 Stars) |
|
|
iRANian wrote on Thu, 09 March 2017 15:19 | How would you go about measuring server frame time? Considering sfps is a shit measure for server lag.
Now for calculating server frame time recording pairing 'current frame number' and ('current time in milliseconds' - 'last time in milliseconds') ought to work right.
But how could I measure all the issues caused by Observers/Scripts and hooks and plugins? Do i need to use assembly hooking? I'd like to be able to record the lag caused by having all the extra script and logic running. I know I can modify the Dragonade source code for some of it, but there are also things I can't measure when just modifying the Dragonade source code.
|
That would be neat. There is a million and one observers running on god knows objects.
iRANian wrote on Thu, 09 March 2017 15:19 |
I'm pretty sure Dragonade contains some slowdowns when the server is running for some time, for example on Rencorner you can see the sfps drop from 100 to 97 after server is running for a while. This causes infantry to suffer. It looks like just a 3 SFPS drop but it's averaged over a second so it's probably a very long pause.
|
It is likely my bad coding haha.
[Updated on: Wed, 15 March 2017 00:34] Report message to a moderator
|
|
|
Re: Measuring server frame time? [message #492090 is a reply to message #492071] |
Wed, 15 March 2017 02:02 |
iRANian
Messages: 4308 Registered: April 2011
Karma: 0
|
General (4 Stars) |
|
|
I'd start with just doing an OnThink() hook which writes to a dynamic vector of a struct FrameTime which looks like this:
struct FrameTime {
int frame;
int msDiffSinceLastFrame; // the milliseconds difference since last frame
}
In the init function of the plugin you initialize the dynamic vector class with type struct FrameTime and a global called FrameLastTime which stores the last frame time in milliseconds (the milliseconds expired since Windows was started). Use timeGetTime() to initialize this var. the The init function also needs to use timeBeginPeriod(1); to set the timer resolution to 1 millisecond.
In onThink you do:
int currentTimeInMs = timeGetTime();
int diffInMs = currentTimeInMs - FrameLastTime;
FrameLastTime = currentTimeInMs;
DynamicVectorClass.add( new FrameTime { .Frame = The_Game()->Get_Current_Frame(), .msDiffSinceLastFrame = diffInMs });
In the gameover hook you add:
Function_To_Write_CSV_File_From_Dynamic_Vector_Of_FrameTimes();
for each FrameTime in DynamicVectorClass_Of_FrameTImes
-->delete FrameTime;
DynamicVectorClass_Of_Frame_Times.Clear();
The function to write frametimes just does a for each loop on every the dynamic vector of frame times and does a fprintf(file, "%d,%d", FrameTime->frame, FrameTime->msDiffSinceLastFrame);
Don't forget to call fopen() and fclose(). the filename should contain the start date and time of the map, map name etc.
Then you open the .csv text file that is written and create a graph in Excel or something.
Main issue is that the Windows timer functions we're using might not be high resolution enough...the Microsoft documentation is warning about it. We can use more high resolution timers if that's an issue.
Another issue is that the timeGetTime() functions returns the milliseconds since Windows was started, as a 32-bit value. This wraps around after Windows has been running for 48 days (so after 48 days, timeGetTime() will start returning from 0)
Long time and well respected Renegade community member, programmer, modder and tester.
Scripts 4.0 private beta tester since May 2011.
My Renegade server plugins releases
[Updated on: Wed, 15 March 2017 02:03] Report message to a moderator
|
|
|
|
|
|
|
|
|
Re: Measuring server frame time? [message #492113 is a reply to message #492102] |
Fri, 31 March 2017 07:18 |
|
Gen_Blacky
Messages: 3250 Registered: September 2006
Karma: 1
|
General (3 Stars) |
|
|
iRANian wrote on Fri, 24 March 2017 14:48 | GENBLACKY
|
Sorry I have been busy and forgot to respond. Why never on irc!
I have been working on Brenbot recently. A server resource tool would a cool idea. It would be very cool to determine processing time and such of observers/scripts long running stuff. But really is unnecessary. ( still would do it for the fun )
WD has been doing his thing and testing da 1.9.0.
Jerad Gray wrote on Sun, 26 March 2017 18:58 |
dblaney1 wrote on Fri, 24 March 2017 17:53 | The best way to reduce lag on the server is to run the default sfps of 60. The more even the fps the better. Running 100 will just make things laggier.
|
And have the clients run with vsync on as well, if both can run 60fps it minimalizes the physics inconsistencies.
|
yep and yep
[Updated on: Fri, 31 March 2017 08:01] Report message to a moderator
|
|
|
|
Re: Measuring server frame time? [message #492115 is a reply to message #492113] |
Fri, 31 March 2017 10:02 |
dblaney1
Messages: 358 Registered: March 2014 Location: United States
Karma: 0
|
Commander |
|
|
Gen_Blacky wrote on Fri, 31 March 2017 07:18 |
iRANian wrote on Fri, 24 March 2017 14:48 | GENBLACKY
|
Sorry I have been busy and forgot to respond. Why never on irc!
I have been working on Brenbot recently. A server resource tool would a cool idea. It would be very cool to determine processing time and such of observers/scripts long running stuff. But really is unnecessary. ( still would do it for the fun )
WD has been doing his thing and testing da 1.9.0.
Jerad Gray wrote on Sun, 26 March 2017 18:58 |
dblaney1 wrote on Fri, 24 March 2017 17:53 | The best way to reduce lag on the server is to run the default sfps of 60. The more even the fps the better. Running 100 will just make things laggier.
|
And have the clients run with vsync on as well, if both can run 60fps it minimalizes the physics inconsistencies.
|
yep and yep
|
Most of the cpu time is not really related to scripts per say. The engine code is way heavier than anything the scripts or DA is doing. Lots of collision math and raytraces etc. Plus all the network stuff. Sending updates to a bunch of players seems to be one of the larger chunks of cpu usage. I usually can have hundreds of bots fine but once you hit like 20-30 players the cpu usage goes up a lot.
[Updated on: Fri, 31 March 2017 10:27] Report message to a moderator
|
|
|
Re: Measuring server frame time? [message #492116 is a reply to message #492071] |
Sat, 01 April 2017 00:49 |
iRANian
Messages: 4308 Registered: April 2011
Karma: 0
|
General (4 Stars) |
|
|
It'a not that, it's that the server will hang like 50-100 ms from time to time, causing stutter in player movement on the server. SFPS counters can't detect it, you need a frametime counter. The Source engine has one built in for servers iirc.
Long time and well respected Renegade community member, programmer, modder and tester.
Scripts 4.0 private beta tester since May 2011.
My Renegade server plugins releases
|
|
|
Re: Measuring server frame time? [message #492117 is a reply to message #492071] |
Sat, 01 April 2017 03:42 |
|
I dont know how useful they are but the engine has values called FrameSeconds and RealFrameSeconds.
Put these in a source file somewhere and access them like any other float variable
REF_DEF2(float, FrameSeconds, 0x00857290, 0x00856478);
REF_DEF2(float, RealFrameSeconds, 0x00857294, 0x0085647C);
You could stick in a Think hook somewhere and see what those variables look like (not sure what the difference between the 2 actually is though)
Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
|
|
|
|
|