Test_User reports: /mail is slow, hangs the serve ... #4531
Labels
No Label
1. kind/balancing
1. kind/breaking
1. kind/bug
1. kind/construction
1. kind/documentation
1. kind/enhancement
1. kind/griefing
1. kind/invalid
1. kind/meme
1. kind/node limit
1. kind/other
1. kind/protocol
2. prio/controversial
2. prio/critical
2. prio/elevated
2. prio/good first issue
2. prio/interesting
2. prio/low
3. source/art
3. source/client
3. source/engine
3. source/ingame
3. source/integration
3. source/lag
3. source/license
3. source/mod upstream
3. source/unknown
3. source/website
4. step/approved
4. step/at work
4. step/blocked
4. step/discussion
4. step/help wanted
4. step/needs confirmation
4. step/partially fixed
4. step/question
4. step/ready to deploy
4. step/ready to QA test
4. step/want approval
5. result/cannot reproduce
5. result/duplicate
5. result/fixed
5. result/maybe
5. result/wontfix
ugh/petz
ugh/QA main
ugh/QA NOK
ugh/QA OK
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: your-land/bugtracker#4531
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Test_User reports a bug:
Player position:
Player look:
Player information:
Player meta:
Log identifier
Profiler save:
Status:
Teleport command:
Compass command:
according to the profiler, mail can take up to 5.8s on a server step.
There are multiple problems with the mail implementation:
mail.get_storage_entry()
is often called to get user's mailbox. Mailbox is stored as monolithic JSON string of all inbox/outbox mails, and it's parsed each and every time (with 100+ mails it starts becoming noticeable and server spends significant amount of time doingJson::OurReader::decodeString
):02853fc3d0/storage.lua (L17)
Each mail has UUID assigned, but it's not used in a smart way. For example, function for deleting mails just iterates over every mail in a mailbox and every to-be-deleted id. Basically this code has quadratic-like running time:
O(total_mails*ids_to_delete)
. As an added bonus: no earlybreak
when mail is found. Should just use lua tables properly to lookup mail in constant time.9679251249/storage.lua (L112)
just iterates over every mail when it's not necessary, e.g. to count unread ones:
9679251249/hud.lua (L45)
I migrated the modstorage on the testserver to postgres.
Want to try again there?
Turns out, for each mail displayed,
get_setting()
is called:9679251249/ui/inbox.lua (L63)
which in turn calls
mail.get_storage_entry(playername)
9679251249/storage.lua (L275)
That means, for every mail in the mailbox, it re-reads and re-parses the JSON string containing the whole mailbox.
If we just move this get_setting() outside the loop, at least the display will lag server much less. Same could apply to other parts of the code it seems.
It might be helpful if no mails of the /bug and /reports were sent in the time until the bug is fixed. It's enough to get them displayed in the chat and here on Gitea.
How to use mailing lists?
Maybe make bugreport mails subscribe only mailing list?
And since they are public anyway, it's not a problem if non-staff subscribe to them.
Other mails are much more rare and less of a problem.
A big thank you to @whosit for solving the mail problem.
@whosit is this live? or fixed?