Author Topic: LagDetector  (Read 8374 times)

0 Members and 1 Guest are viewing this topic.

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
LagDetector
« on: March 26, 2016, 12:47:22 AM »

  /)          /)                       
 // _   _   _(/  _ _/_  _  _ _/_ _____
(/_(_(_(_/_(_(__(/_(___(/_(__(__(_)/ (_
      .-/                             
     (_/           
   
                 
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
« Last Edit: March 27, 2016, 06:34:59 PM by Buzzkill »

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: LagDetector
« Reply #1 on: March 28, 2016, 07:29:57 AM »
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
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: LagDetector
« Reply #2 on: March 28, 2016, 06:28:52 PM »
I didn't know you could use SysTime() and CurTime() to detect if a server is overloaded. Useful! Thank you for sharing. :D

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: LagDetector
« Reply #3 on: March 28, 2016, 06:56:52 PM »
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: [Select]
local SysCurrDiff = SysTime() - CurTime() -- current differential
deltaSysCurrDiff = math.Round(SysCurrDiff - lastSysCurrDiff, 6) -- change in differential since last check
lastSysCurrDiff = SysCurrDiff
return deltaSysCurrDiff

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.


Offline PAL-18

  • Full Member
  • ***
  • Posts: 142
  • Karma: 1
Re: LagDetector
« Reply #4 on: April 16, 2018, 01:46:55 AM »
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

Offline Tw2Stefan

  • Newbie
  • *
  • Posts: 4
  • Karma: 1
Re: LagDetector
« Reply #5 on: April 16, 2018, 11:15:17 AM »
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
The Git is not for this specific addon, but is a compilation of scripts that the developer has written. The file in question is simply a different script. It's not needed to run the "LagDetector". It also has a thread here: https://forums.ulyssesmod.net/index.php/topic,9613.0.html

Offline PAL-18

  • Full Member
  • ***
  • Posts: 142
  • Karma: 1
Re: LagDetector
« Reply #6 on: April 16, 2018, 12:15:30 PM »
That's fine and dandy but the developer at the least could have either removed their steam group from that file and replace with a dummy url or document the change users need to perform to get it to use their steam group instead.  Simply not mentioning it doesn't make it right, especially when it gives someone else's steam group an unfair advantage on your server.
« Last Edit: April 16, 2018, 12:42:04 PM by PAL-18 »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: LagDetector
« Reply #7 on: April 16, 2018, 06:42:16 PM »
This isn't the release for steamteam.
Buzzkill clearly describes it in the SteamTeam release thread, as Tw2Stefan mentioned already
Quote
An example configuration is included in source, with notes on important values. This is probably the best approach to configuration documentation for now.

No malice intended.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline PAL-18

  • Full Member
  • ***
  • Posts: 142
  • Karma: 1
Re: LagDetector
« Reply #8 on: April 17, 2018, 02:22:04 PM »
Ah ok, i just panicked when i saw that file on my server.