Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message window with many messages slows down game massively #5898

Open
hessenfarmer opened this issue May 2, 2023 · 12 comments
Open

Message window with many messages slows down game massively #5898

hessenfarmer opened this issue May 2, 2023 · 12 comments
Labels
bug Something isn't working memory & performance Fix bottlenecks, memory leaks, ASan, ... multithreading Deadlocks, race conditions, mutex trouble, … ui User interface

Comments

@hessenfarmer
Copy link
Contributor

Describe the bug
If your message window accumulated a lot of messages (approx more then 50 and up - easy to achieve in a long game) the game gets slowed down very much. even selection of messages or single deletions are delayed. only CTRL-A ->del might help although taking seconds

To reproduce

  1. Start a game
  2. play long enough and send geologists and place lumberjacks quarries without usable immovables nearby to trigger messages
  3. when messgaes have accumulated open the messages window
  4. game and UI is slowed

Expected behavior
Keep the performance when viewing messages

@hessenfarmer hessenfarmer added the bug Something isn't working label May 2, 2023
@Noordfrees Noordfrees added memory & performance Fix bottlenecks, memory leaks, ASan, ... multithreading Deadlocks, race conditions, mutex trouble, … ui User interface labels May 2, 2023
@frankystone
Copy link
Contributor

I rarely delete messages and my message box is always full of messages, i never noticed a slow down of the game when opening the message box. Opening the minimap slows down the game for me, but i think this might be because i use always a debug build.
@hessenfarmer does using a release build also slow down the game?

@hessenfarmer
Copy link
Contributor Author

it does I normally use release builds to test things as they compile (or more precise link) much quicker and I only use debug if necessary.

@hessenfarmer
Copy link
Contributor Author

@frankystone do you have the message box open all the time? or do you open and close it frequently.
My current guess is that the sorting code implemented in the window code just starts when opening the window and may cause the slow down as I do not have the window open all the time.

@frankystone
Copy link
Contributor

I open it very rarely. Mostly to lookup for geologist messages. Here is a savegame with 140 messages in the inbox. I notice no slow down with this amount of messages.

wl_autosave_02.zip

@hessenfarmer
Copy link
Contributor Author

hessenfarmer commented May 8, 2023

ok here is a savegame which literally stops the game while being open. (more then 1000 messages maybe I remembered the amount wrong in the first post.)
ffff.zip

@hessenfarmer
Copy link
Contributor Author

I open it very rarely. Mostly to lookup for geologist messages. Here is a savegame with 140 messages in the inbox. I notice no slow down with this amount of messages.

wl_autosave_02.zip

this has nearly the same effect on my windows machine game slows down immediately only if i filter to a reasonable amput the game is running normally

@Noordfrees
Copy link
Member

I can confirm that a message window like that causes the stuttering. The problem is probably that we create an Objects mutex while the UI is self-updating:

current_think_mutex_.reset(
new MutexLock(MutexLock::ID::kObjects, [this]() { handle_notes(); }));
do_think();
current_think_mutex_.reset();

The message window on every UI cycle iterates over all currently shown messages to see whether they're still valid, and then over the player's entire inbox to check for each visible message whether it's in the list. I don't immediately see an easy way to mitigate this for such a large inbox though.

@frankystone
Copy link
Contributor

Over 1 thousand messages :-D

Maybe there can be an auto archive function? Say e.g. max 500 recent messages and if there are more they get archived, or time based, depending on the time autosaves will be created: If autosave time is 10 Minutes all messages older than 10 Minutes get archived (this is probably too fast, so autosave time * 2 would maybe fit better).

@hessenfarmer
Copy link
Contributor Author

As said above I have nerly the same effect with the savegame provided by @frankystone

@hessenfarmer
Copy link
Contributor Author

My first thought without knowing the exact cause was to eventually maintain the list outside of the window, to better distribute computing time. But I don't know whether this would be doable

@Noordfrees
Copy link
Member

I wouldn't like messages being archived automatically, but we could show only the first 20 or so messages with a "show more (+980)" button that loads the next batch of 20 messages (like in long GitHub conversation threads). Or pagination with only 10 messages per page. What do you think?

My first thought without knowing the exact cause was to eventually maintain the list outside of the window, to better distribute computing time. But I don't know whether this would be doable

How do you mean? The actual message queue is a property of the game logic, complete with PlayerCommands to set the read/archived state of messages; and the messages window provides a representation of that queue (which requires constant cross-updating, as the queue contents change frequently, e.g. when a map object is deleted its associated messages disappear).

@hessenfarmer
Copy link
Contributor Author

I wouldn't like messages being archived automatically, but we could show only the first 20 or so messages with a "show more (+980)" button that loads the next batch of 20 messages (like in long GitHub conversation threads). Or pagination with only 10 messages per page. What do you think?

pagination is a very good idea. +1

My first thought without knowing the exact cause was to eventually maintain the list outside of the window, to better distribute computing time. But I don't know whether this would be doable

How do you mean? The actual message queue is a property of the game logic, complete with PlayerCommands to set the read/archived state of messages; and the messages window provides a representation of that queue (which requires constant cross-updating, as the queue contents change frequently, e.g. when a map object is deleted its associated messages disappear).

Ok forget it thanks for the explanation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working memory & performance Fix bottlenecks, memory leaks, ASan, ... multithreading Deadlocks, race conditions, mutex trouble, … ui User interface
Projects
None yet
Development

No branches or pull requests

3 participants