4/8/2024 - devlog
Michi describes how he fixed the latest performance problem.
Michi (molp)
It was another short week for me, due to a public holiday and a day off. Nonetheless, I was able to fix a performance problem that lead to an increased number of server restarts over the last 10 days or so.
Right now, we keep contracts that are in a terminal state (rejected, breached, cancelled, terminated, fulfilled) for about 45 days before removing them entirely. We need them to calculate the company ratings and be able to show the history of contracts in the CONTS
command.
Since we use the same contract component for faction agents, they also still have all contracts of the past six weeks. For a regular company this is not a problem, but faction agents have tons of contracts. This lead to an excessive memory usage which eventually lead to out-of-memory exceptions when the automatic snapshot generation tried to create snapshots of these actors.
The fix was relatively simple: Since we don't need these contracts to generate a rating for faction agents, we can reduce the time we keep them around to a couple of days. For a typical faction agent that meant that we could delete ~30,000 contracts with 160,000 associated contract conditions.
After deploying the changes, the memory issues were resolved and the current uptime is > 5 days without a restart.
I also got a few smaller tasks on the politics update done. Motions can now be deleted, if they are still a draft and voting has not yet begun. The voting phase now automatically ends if all members of parliament cast their vote. The results of the vote are immediately calculated and the motion's status updated accordingly. By the way, if there is a tie, the governor's vote counts double. If the governor abstained, the motion fails.
As always: we'd love to hear what you think: join us on Discord or the forums!
Happy trading!