CntoDev / cnto-additions

Other
0 stars 1 forks source link

Performance test frame and scheduler consistency #13

Open freghar opened 3 years ago

freghar commented 3 years ago

Testing frame time consistency (also unscheduled code consistency) can be done by running a deterministic piece of code via EachFrame mission event handler, and logging diag_deltaTime (ie. via pushBack) to some array. After the benchmark part is done, another piece of code can look at the time differences and either output some deviation value or graph the deltas. Note that whatever is running concurrent to this benchmark needs to be consistent enough to not trip the delta change due to its nature - ie. no unit spawning, no zeus creation, etc. The idea here is to uncover potential unscheduled scripts that lower the "minimum FPS" value and cause the game to experience micro-stutter, typically when a mod maker uses unscheduled code (to perform a time-heavy task), but doesn't realize it (ie. CBA_fnc_waitUntilAndExecute).

OTOH, the scheduler performance can be killed without a significant FPS impact - if a modmaker makes an intensive enough scheduled script that exceeds 3ms everytime it runs, other scripts can experience wildly inconsistent scheduling delays or even starvation (if there are many performance-heavy scripts running). Log diag_deltaTime from a scheduled script and observe how consistently the scheduler runs it.

Note that either of these could be combined with vanilla functionality too (ie. some editor modules), as long as the action tested is consistent enough.

milivojm commented 3 years ago

https://community.bistudio.com/wiki/diag_activeScripts https://community.bistudio.com/wiki/diag_activeSQFScripts https://community.bistudio.com/wiki/diag_activeMissionFSMs

might come handy too in this. For example if diag_deltaTime exceeds some threshold we could log active scripts too. Although, this seems to be for scheduled scripts, is there a way to see unscheduled ones too?

freghar commented 3 years ago

Unfortunately no, you can only check how many are running (by creating a new one and getting an index to it) or remove them (one by one or all at once).

milivojm commented 3 years ago

Did you try this https://steamcommunity.com/sharedfiles/filedetails/?id=1652506957

I haven't got any experience with it.

freghar commented 3 years ago

Did you try this https://steamcommunity.com/sharedfiles/filedetails/?id=1652506957

I haven't got any experience with it.

Yes, but it's mostly useful only for profiling specific scripts. Similar to https://community.bistudio.com/wiki/diag_captureSlowFrame