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

Optimize connecting to a server with many messages #664

Merged
merged 3 commits into from
Sep 26, 2021

Conversation

lmoureaux
Copy link
Contributor

This goes from O(n^3) complexity to mostly O(n). Layout of the message widget was the dominant contribution in profiles when connecting to LTEx24. After these changes, it becomes invisible.

scrollToBottom() was called on the table widget once for every message, which
triggered a new text layout every time, with O(n^2) complexity. Call it only
after receiving a batch of messages for hopefully going down to O(n)
complexity.

Also use the opportunity to switch to a more lightweight QListWidget and adjust
the themes accordingly.

See longturn#584.
The code was still calling scrollToBottom() for every event because they are
sent one by one, resulting in O(n^2) complexity. Instead of calling it
directly, schedule a single call for when the server indicates that it's done
processing.

With this change, the layout of the message widget becomes invisible in
profiles.

See longturn#584.
When the server sends a message outside of any request (e.g. when a unit is
killed by someone else in real time), there is no way to know when it will be
done sending, thus scroll immediately. This shouldn't be a large performance
hit since the server is unlikely to send hundreds of messages this way.
@lmoureaux lmoureaux merged commit 245a58f into longturn:master Sep 26, 2021
@lmoureaux lmoureaux deleted the bugfix/optimize-connect branch September 26, 2021 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant