OTS Statistics by kondra (otclient@otclient.ovh) - #4306
Conversation
|
This is promising. I am looking into it, will probably require some rewriting to fit the standards of the rest of the code though. Do you mind if I push to your branch? |
Cherry pick from otland/forgottenserver#4306
|
For lambda functions I create this macro: |
Did you test it on Windows and Linux?
I made TFS 1.4 official commit/PR, as it was only version I had on release time. I'm very busy at work :( Push it to YOUR branch. Just remember to mention EDIT: Did not test it myself, but someone sent me report like that on Discord. g_scheduler.addEvent(createSchedulerTask(walkDelay, [=, id = getID()]() { g_game.forceRemoveCondition(id, type); }));with: g_scheduler.addEvent(createSchedulerTask(walkDelay, ([=, id = getID()]() { g_game.forceRemoveCondition(id, type); }))); |
|
Tested on Windows VS code and it reports all the complete lambda function Please add me the credits as well. |
|
Shouldn't the addLuaStats be in protectedCall instead of callFunction? |
I found work around for lambda functions: https://otland.net/threads/tfs-1-4-ots-statistics-c-lua-sql-by-kondra.283717/page-4#post-2744107 Other way to implement this system is to add class in each function you want to track, like canary does: AutoStat measure("name of function");It will be reported in |
|
@ericcobblepot |
I've got permission from kondra (otclient@otclient.ovh) to release this code. He only requested to leave information about author
kondra (otclient@otclient.ovh)in commit message.It's well known 'OTS stats' system. It tracks all dispatcher thread tasks, Lua function calls and SQL queries.
It generates files
dispatcher.log,lua.logandsql.logindata/logs/statsthat looks like:Report interval is configurable in
config.lua.It also reports slow/very slow function calls in files
dispatcher_slow.log,lua_slow.logandsql_slow.log. Ex. server start takes over 50 ms, it's reported as very slowdispatcher_very_slow.log:Lua
startup.luaexecutes over 10 ms, it's reported as slow:SQL took over 10 ms, it's reported as slow:
Slow/very slow time is configurable in
config.luaThere are also
special.log,special_slow.logandspecial_very_slow.log, which report your custom statistics. Ex. to report decay time of items, ingame.cppunder:add:
String
internalDecayItemwill be used for total CPU usage report. Second parameter (item ID) will be reported inslowandvery_slowlogs. In this case, it would say which item ID decayed over 10 ms (single item decay time, not all items with this item ID).Most OTSes pass player name as second parameter. It let them track which player generated 'slow' actions - lagged OTS.
It's MR draft
There are few things to test:
addEventLua functions are reported (is itUnknownor prints whole function Lua code), when you pass anonymous function ex.:Unknownor prints whole function C++ code) ex.:Feature implementation could also be better separated using
STATS_ENABLEDdefinition. Right now, when you compile it withoutSTATS_ENABLED, it still pass function name for every dispatchertask, but it passes empty string:https://github.com/gesior/forgottenserver-gesior/blob/0ad4be6cab3e335e6f7dc767722f70ee0c849be8/src/stats.h#L17-L23