Ulysses Stuff > Releases

LagDetector

(1/2) > >>

Buzzkill:

  /)          /)                       
 // _   _   _(/  _ _/_  _  _ _/_ _____
(/_(_(_(_/_(_(__(/_(___(/_(__(__(_)/ (_
      .-/                             
     (_/              
                 
GMod Server Lag Detection Routine
Written by Buzzkill    --    thehundredacrebloodbath.com
https://github.com/100acrebb/thab_tools
http://steamcommunity.com/sharedfiles/filedetails/?id=654334461

LagDetector is a simple tool to help detect and manage server-side lag.  It uses differences between SysTime() and CurTime() to detect
unexpected server lag, and once these deltas have exceeded a certain threshold, action can be taken to help correct.

These thresholds and actions are configurable through cvars:
lagdet_range      - if the difference between SysTime and CurTime exceeds this value in a frame, we have detected frame lag and the system increments the lag counter. Default is 0.07
lagdet_count      - if the lag counter reaches this value, we have detected server lag and we execute lagdet_execute. Default is 5
lagdet_quiet      - indicates how long we must go (in seconds) with no frame lag before our lag counter resets to 0.
lagdet_execute      - the console command(s) to execute if we detect server lag. Default is a simple say
lagcount_meltdown   - if we detect this many frame lags without a reset, we execute lagexecute_meltdown. Default is 100
lagexecute_meltdown   - these console command(s) are executed in the event of massive lag.  Server is probably in a collision loop or something. Good time to restart the map. Default is a simple say

So, using the defaults..
LagDetector will compare SysTime and CurTime every second.  If the difference between the two >= 0.07, the lag counter increases.
If we go 15 seconds without detecting frame lag, the lag counter resets to 0.
If the lag counter hits 5, we execute the commands in lagdet_execute
If the lag counter hits 100, we execute the commands in lagexecute_meltdown

Stickly Man!:
Neat! I've seen several complaints about lag caused by CurTime() issues- this looks like a good way to combat it without having someone on all of the time. ;D

Timmy:
I didn't know you could use SysTime() and CurTime() to detect if a server is overloaded. Useful! Thank you for sharing. :D

Buzzkill:
np, and thanks.

Yep -  basically CurTime will drag as the server lags, and we detect a growing differential between Sys and Cur each frame.

each frame..


--- Code: ---local SysCurrDiff = SysTime() - CurTime() -- current differential
deltaSysCurrDiff = math.Round(SysCurrDiff - lastSysCurrDiff, 6) -- change in differential since last check
lastSysCurrDiff = SysCurrDiff
return deltaSysCurrDiff
--- End code ---

every time we return something > 0.07, we're lagging a bit.  0.07 is somewhat arbitrary, and where I landed after tuning a bit.  You could, of course, set it lower or higher and/or adjust the count threshold to modify sensitivity.

setting lagdet_verbose to 1 will show the current calculation every second in server console, and not just during periods of detected lag.  Forgot to mention that.

PAL-18:
I dont know if the developer forgot to mention this or he added this maliciously, but this addon also gives members of (what i assume is his) steam group bonus points from point mod.

The file in question is in: lag_detector\lua\autorun\server\steamteam.lua

Navigation

[0] Message Index

[#] Next page

Go to full version