Page 1 of 2

Console memory lag issue

Posted: Tue Jul 14, 2015 10:28 am
by unknownna
0001897: CPU-like lag when picking up items or when flag is taken/dropped/returned after a dozen map changes || Console memory issue

There seems to be some serious memory issues with ZDoom's console. The more lines of text there are in the buffer, the more the gameplay lags/stutters when new messages are printed, e.g. when picking up items. This is very frustrating to play with in competitive settings since it throws off your movement prediction.
console_lag.wad
(3.31 KiB) Downloaded 56 times
Steps to reproduce:

1. zdoom -iwad doom2.wad -file console_lag.wad +map map01 +sv_itemrespawn 1 +cl_capfps 1 +msg 0
2. Pick up the armor bonuses. Notice how smooth the movement is.
3. Copy-paste:

Code: Select all

cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist;cmdlist
into the console. Depending on how powerful your CPU is you might have to repeat this step.
4. Pick up the armor bonuses. Notice how choppy the movement is. If you repeat step 3, it'll get even choppier.
5. "msg 1" in the console.
6. Pick up the armor bonuses. Notice how smooth the movement is again due to the lack of printed messages.

Make sure that cl_capfps is set to 1 to really notice and observe it.

This issue becomes very noticeable after approx. 1.5-2 hours of high-intensity CTF gameplay on Zandronum due to all the messages that pile up in the console (obituaries, chat, join/connect/disconnect and flag messages). ZDaemon apparently worked around this by not storing too many lines in the console and also by increasing whatever buffer there is (according to the changelog), thus the gameplay remains 100% smooth there.

Re: Console memory lag issue

Posted: Tue Jul 14, 2015 11:25 am
by Graf Zahl
Have you tried playing around with the con_buffersize CVAR?
It may be necessary for Zandronum to set another limit here. ZDoom's is indeed unlimited and never deletes any console content at its default setting.

Re: Console memory lag issue

Posted: Tue Jul 14, 2015 12:47 pm
by unknownna
I tried to raise the value, but it didn't seem to help at all. So is it safe to assume that this will not be changed in ZDoom at all in any shape or form?

Edit:

Actually, ZDoom and ZDaemon seem to store the same (or similar) amount of lines, so the problem must be something else.

Re: Console memory lag issue

Posted: Tue Jul 14, 2015 1:26 pm
by Graf Zahl
I'M closing this now. Checking Zandronum's source I noticed that it still uses the old console buffer. I replaced that in ZDoom sometime last year so any issues with the old version are not relevant for ZDoom anymore.

Re: Console memory lag issue

Posted: Tue Jul 14, 2015 1:34 pm
by unknownna
But it's still relevant. I still notice the behavior in zdoom-x64-2.8pre-1662-gfe2e293.7z.

Re: Console memory lag issue

Posted: Tue Jul 14, 2015 2:07 pm
by Graf Zahl
That's why there's a CVAR to limit the buffer size. I'm not going to disable the option to keep all console content just because it may cause slowdowns after hours of play.

Re: Console memory lag issue

Posted: Tue Jul 14, 2015 2:21 pm
by unknownna
So, by decreasing the con_buffersize value, it should improve the behavior? From what I can tell it doesn't improve anything. The lowest value is apparently 128. There's no difference between -1, 128 or 2147483647.

Re: Console memory lag issue

Posted: Tue Jul 14, 2015 2:56 pm
by Graf Zahl
Then I have no idea what's happening but it can't be the console buffer.

Re: Console memory lag issue

Posted: Tue Jul 14, 2015 3:02 pm
by unknownna
But it must have something to do with messages that are printed since the lag that occurs when picking up items goes away if you change "msg" from 0 to 1.

Re: Console memory lag issue

Posted: Tue Jul 14, 2015 3:54 pm
by Graf Zahl
What happens if the console is full and you clear it with the 'clear' command?

Re: Console memory lag issue

Posted: Tue Jul 14, 2015 7:18 pm
by unknownna
Unfortunately nothing happens. It clears out the text, but it still lags/stutters just as much. The only way to work around this currently is to quit and restart (g)zdoom/zandronum.exe.

Re: Console memory lag issue

Posted: Tue Jul 14, 2015 9:25 pm
by unknownna
This didn't happen in earlier versions of ZDoom (2.1.1). I'll investigate this further.

1.22 - Very fast and very stable.
1.23b33 (ZDaemon) - Same as above.
2.0.40 - Same as above.
2.0.63a - Very fast, but crashes if the command is pasted too often in the console during gameplay.
2.0.90 - Same as above.
2.0.94 - Same as above.
2.0.95 - Starts to lag slightly when pasting the command. Also crashes if the command is pasted too often in the console during gameplay.
2.1.0 - Same as above, but it doesn't crash anymore.
2.1.1 - Same as above.
2.1.2 - Starts to lag more when pasting the command.
2.1.3 - Same as above.
2.1.4 - Same as above.
2.1.5 - Same as above.
2.1.6 - Same as above.
2.1.7 - Same as above.
2.2.0 - Problem starts to appear. Starts to lag considerably more when pasting the command. Gameplay starts to lag.

Re: Console memory lag issue

Posted: Wed Jul 15, 2015 12:50 am
by Graf Zahl
Thanks for mentioning 2.0.95. In that version the edit control was added to display the error window. And THAT definitely can cause problems. (And guess what: This actually never gets cleared at all...) And in 2.2.0 it was replaced with a RichEdit control, therefore the increase in lag.

I think the best course of action here will be to omit pure in-game messages from being added there, that'll require quite a bit of work, though (and special handling for Zandronum's own messages.)

Re: Console memory lag issue

Posted: Wed Jul 15, 2015 1:06 am
by Graf Zahl
As a quick test: Comment out the I_PrintStr call in c_console.cpp:PrintString to see if this helps resolve the lag.

Re: Console memory lag issue

Posted: Wed Jul 15, 2015 1:24 am
by unknownna
I don't know how to compile builds since I'm not a coder/programmer, so unfortunately I can't test it.