What are performance numbers in Debug Mode show-time-usage?

Anything that prevents you from playing the game properly. Do you have issues playing for the game, downloading it or successfully running it on your computer? Let us know here.
Post Reply
mk-fg
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Wed May 30, 2018 11:01 am
Contact:

What are performance numbers in Debug Mode show-time-usage?

Post by mk-fg »

Hi.

I've been wondering how changes to code in on_tick of a mod have been affecting game performance.
And looking at F5 screen with show-time-usage enabled, "Update:" numbers seem to have by-mod breakdown and look useful, but can't find what they stand for.

For example, a line for each mod in "Update:" section like "mod-Bottleneck: 0.118/0.254/1.537" - what does each one of these three numbers (separated by slashes) represent?

Only info I was able to find on these so far was basically "first number high = bad", which is better than nothing, but not very helpful either.
Would appreciate any additional information.

More specific questions:

- Are these numbers stand for cpu time that lua thread took to run stuff (e.g. that mod hooks for example line), monotonic time between start/end (as in "clock_gettime(CLOCK_MONOTONIC, ...)") or rtc/wall-clock time?
- First number - is it time it took to run arbitrary last entry point from that mod?
- - Maybe sum of time for all entry points during last game logic update?
- - Maybe some kind of average of all calls to that mod code during last update?
- - Maybe not average at all, but sum, min, max, or something else entirely?
- What does the second number mean?
- What is the third one? Some kind of sum over time?
- How often are they updated (esp. second and third one)?
- How roughly accurate these numbers are? E.g. if it's cpu time, is it sampled per-process as sum of all threads, so that e.g. graphical settings will change these numbers too?

This is important for performance optimization, as - for example - looking at max or average value while tweaking one of N hooks in a mod can be pointless, or comparing non-cpu times when you have e.g. video rendering running in the background is probably a bad idea (as they'll be really biased by that, even with the same code).

Do realize that these might be hard questions, esp. for non game developers, just wanted to hint at as much useful info as possible, in case it might be known/available - will be happy with any clarifications, really :)
Thanks in advance!

Jap2.0
Smart Inserter
Smart Inserter
Posts: 2339
Joined: Tue Jun 20, 2017 12:02 am
Contact:

Re: What are performance numbers in Debug Mode show-time-usage?

Post by Jap2.0 »

Time in ms - I believe it's some combination of min, max, avg, and/or last update. I can't tell you much more until I have the game open as reference, so if I can find more I'll tell you later.
There are 10 types of people: those who get this joke and those who don't.

mk-fg
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Wed May 30, 2018 11:01 am
Contact:

Re: What are performance numbers in Debug Mode show-time-usage?

Post by mk-fg »

As it came up recently in discord, to answer this old question of mine:
Current https://wiki.factorio.com/Debug_mode has this info for show-time-usage.

- Internal statistics about how long some calculations take, in milliseconds per tick.
- Time is shown as average/min/max of the last 100 ticks, interval can be changed with /perf-avg-frames.
- Minimum values exclude zeroes (e.g. from ticks where no mod hooks were run).
- Overall calculation delays (some are parallel) must be under 16.6 ms to maintain normal framerate at 1x speed with 60 ticks per second.

So for "mod-Bottleneck: 0.118/0.254/1.537" example from the original post:

- 0.118 is average ms it takes the game to process mod event handlers per tick, including 0 values in there, which is why it's lower than the second value (min).
- 0.254 is the minimum ms mod takes on ticks when its hooks run. Value clearly above average suggests that load could've been distributed better in that (very old by now) version of that mod.
- 1.537 as max ms value confirms earlier observation, and is quite a lot to take for one mod, given game target of 60 ticks/second - dozen mods like that will cause lag spikes when such worst-case events run on the same tick.

Afaict "milliseconds per tick" is cpu time, but as game uses >1 OS thread, not all times in that display must sum up to 16.(6) ms on every tick to get proper 60 UPS at 1x game speed.
Not sure which of these are parallel, but for the purposes of modding, all mod-* stuff should probably sum to be less than that in worst-case, or you start getting lag.

Post Reply

Return to “Technical Help”