Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Measuring server frame time?
Measuring server frame time? [message #492071] Thu, 09 March 2017 15:19 Go to next message
iRANian is currently offline  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 Go to previous messageGo to next message
Gen_Blacky is currently offline  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.


http://s18.postimage.org/jc6qbn4k9/bricks3.png

[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 Go to previous messageGo to next message
iRANian is currently offline  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 #492101 is a reply to message #492071] Fri, 24 March 2017 13:48 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
GENBLACKY

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 #492102 is a reply to message #492071] Fri, 24 March 2017 16:53 Go to previous messageGo to next message
dblaney1 is currently offline  dblaney1
Messages: 358
Registered: March 2014
Location: United States
Karma: 0
Commander
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.
Re: Measuring server frame time? [message #492105 is a reply to message #492102] Sun, 26 March 2017 17:58 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3809
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
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.


Re: Measuring server frame time? [message #492110 is a reply to message #492071] Tue, 28 March 2017 14:12 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
vsync causes input lag.

Really noticeable too


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 #492111 is a reply to message #492110] Tue, 28 March 2017 20:08 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3809
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
iRANian wrote on Tue, 28 March 2017 15:12

vsync causes input lag.

Really noticeable too

Depends on the game from my experience.


Re: Measuring server frame time? [message #492112 is a reply to message #492071] Wed, 29 March 2017 00:37 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
It's in every game because triple buffering is using. Only NVIDIA's adaptive sync which they introduced with Pascal is decent.

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 #492113 is a reply to message #492102] Fri, 31 March 2017 07:18 Go to previous messageGo to next message
Gen_Blacky is currently offline  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


http://s18.postimage.org/jc6qbn4k9/bricks3.png

[Updated on: Fri, 31 March 2017 08:01]

Report message to a moderator

Re: Measuring server frame time? [message #492114 is a reply to message #492111] Fri, 31 March 2017 07:27 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
Jerad Gray wrote on Tue, 28 March 2017 21:08

iRANian wrote on Tue, 28 March 2017 15:12

vsync causes input lag.

Really noticeable too

Depends on the game from my experience.



I have to use vsync. I usually have over 1000fps and yea the clipping is bad. But everything displays properly when vsync is on. The input lag is unnoticeable for me.


http://s18.postimage.org/jc6qbn4k9/bricks3.png
Re: Measuring server frame time? [message #492115 is a reply to message #492113] Fri, 31 March 2017 10:02 Go to previous messageGo to next message
dblaney1 is currently offline  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 Go to previous messageGo to next message
iRANian is currently offline  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 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

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
Re: Measuring server frame time? [message #492121 is a reply to message #492071] Wed, 05 April 2017 00:56 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
Thanks, that sounds interesting.

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 #492168 is a reply to message #492071] Fri, 14 April 2017 06:31 Go to previous message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
What about cNetwork::worstFPS? Seems to be doing the same thing.

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
Previous Topic: *wip* renegade coop
Next Topic: Where does the server or client do the always.dat version check?
Goto Forum:
  


Current Time: Thu Nov 21 06:42:04 MST 2024

Total time taken to generate the page: 0.00979 seconds