11-15-2019, 08:46 PM
(This post was last modified: 01-10-2024, 08:38 PM by Deantwo.
Edit Reason: Fixed date year in thread title.
)
Server Load
Server load has grown steadily worse for days, maybe weeks.
Some investigating took me to a small city that was taking almost five minutes to prepare its city report. The mystery grew deeper when the lag was caused by consolidating the inventories of the various buildings in the city into one inventory for the city report. How could that take minutes?
Digging deeper showed that some of the buildings were storing lists of nearly 100,000 different items. That is different items, not counts. Counts of items are just numbers on the items. Differences arise from items that cannot be stacked with other items.
The problem was hidden by the way the inventory is sorted for the city report. The sorting process expected the list items to have unique names. They didn't. I fixed the city report but that fix will not appear until the next client update, not needed for this server fix.
An error was found in an operator== override for old style DNA. The error was introduced recently when a pure base class was implemented for handling old and new DNA uniformly.
The solution fixes inventory lists as they are loaded. You don't have to do anything.
Then we'll find the next most greedy bit of code, eating up CPU time needlessly.
Aspiring programmers should always remember; make it part of your DNA. No CPU instruction is free.
Obsolete Items
Old style cities used to throw away obsolete items. New style cities never throw away obsolete items. This results in long lists of items with slightly different qualities.
New style cities now discard obsolete items when the city report is created. This should further reduce those big lists of inventory items in cities.
Buildings individually maintain their own inventories and residents. Buildings individually decide which of their inventory items are obsolete. The city accumulates all items from all buildings, so the city report may show items that would be considered obsolete if all of the items were considered together.
What makes an item obsolete?
Server load has grown steadily worse for days, maybe weeks.
Some investigating took me to a small city that was taking almost five minutes to prepare its city report. The mystery grew deeper when the lag was caused by consolidating the inventories of the various buildings in the city into one inventory for the city report. How could that take minutes?
Digging deeper showed that some of the buildings were storing lists of nearly 100,000 different items. That is different items, not counts. Counts of items are just numbers on the items. Differences arise from items that cannot be stacked with other items.
The problem was hidden by the way the inventory is sorted for the city report. The sorting process expected the list items to have unique names. They didn't. I fixed the city report but that fix will not appear until the next client update, not needed for this server fix.
An error was found in an operator== override for old style DNA. The error was introduced recently when a pure base class was implemented for handling old and new DNA uniformly.
The solution fixes inventory lists as they are loaded. You don't have to do anything.
Then we'll find the next most greedy bit of code, eating up CPU time needlessly.
Aspiring programmers should always remember; make it part of your DNA. No CPU instruction is free.
Obsolete Items
Old style cities used to throw away obsolete items. New style cities never throw away obsolete items. This results in long lists of items with slightly different qualities.
New style cities now discard obsolete items when the city report is created. This should further reduce those big lists of inventory items in cities.
Buildings individually maintain their own inventories and residents. Buildings individually decide which of their inventory items are obsolete. The city accumulates all items from all buildings, so the city report may show items that would be considered obsolete if all of the items were considered together.
What makes an item obsolete?
- Air and Water are never obsolete in a harsh environment.
- Food is never obsolete if it is edible to the residents of the building.
- Upgrade Modules are obsolete if the inventory contains more of them at a higher Q.
- Other items are obsolete if the inventory is more than half filled with items at least 2 Q's higher than the item. In other words, if the number of items that are itemQ+2 or higher equals or exceed half the storage available, the item is obsolete.