For those who want to play our Home Game, I'm putting saves up on DFFD. They include annual saves for each experiment:
Fork SaveBoulder ExperimentGoblet ExperimentAtom-smasher Fork SaveAtom-smasher results SaveLarge and Small Contraction ExperimentsMedium Contraction Experiment saveIf someone wants to either help run some alternate tests, or else wants to try just continuing some of these experiments for another 10 or 20 years to see if you can get some further FPS degradation, that would help.
Initial Conclusions:- Item count plays a clear and present role in FPS decay. The game decays in FPS to unplayability around 100,000 items. FPS decay seems to be sub-geometric.
- Dead things take up memory forever, and contribute to FPS decay.
- Consuming items in reactions takes up significantly more FPS drain than the act of creating them.
- Destroyed or consumed items, except for creatures that are listed as dead, are properly removed from play and take up no memory and produce no lag.
It is possible that changing the container class for items from an STL Vector to a Deque or custom container class may result in a faster game without having to significantly change aspects of the actual game.
Purpose:
Because of a
certain thread where I postulated that a potential reason for unavoidable fortress entropic decay might be the data structures Toady is using in maintaining an index of all items might be a simple giant item index vector, which may actually never get any sorting, I now have to come up with some sort of proof of concept to actually get a bug report posted.
As such, I'm announcing Operation FPS Bomb, a !!SCIENCE!! project that attempts to understand how the data structures DF uses work, and can be better optimized.
Hypothesis:
Items in this game are tracked in an "Item Index Vector", a giant vector of items that just never really gets cleaned up, and as the game goes on, this vector keeps on getting filled up with items that, even when they are destroyed or permanently removed from the map, are still taking up some sort of reference slot in memory, and the game keeps on checking past them.
This would lead to the inevitable entropic decay of forts, the behavior that people have been complaining about killing even forts where players take every possible precaution and atom-smash all unnecessary objects. If even atom-smashed objects leave a "memory footprint" for lack of a vector sorting, then they will still cause a (lesser) degree of lag, even when they are completely destroyed objects.
Experiment:
Modded dwarves with no need to eat, sleep, drink, or do much of anything will have 21 custom workshops. 20 will all be doing the same thing, and the 21st workshop will be producing a single stone object repeatedly for the duration of the experiment. (This is to control for a possibility of a vector truncation in the case that large numbers of objects being removed will damage the
In the control, the 20 work dwarves will be performing a "Do Nothing" task with no reagent or product. It basically just keeps them sitting at a workshop busy without doing anything.
As the independent variable, the 20 work dwarves will perpetually alternate between a "create 20 stones" reaction and a "destroy 20 stones" reaction. This will create a large list of created and destroyed objects which, if cleanups took place, would result in no different FPS drop than in the control, but if my hypothesis is correct, will result in a noticably lower FPS than the control.
The experiment and control will run for 10 years to give the game enough time to make an appreciable difference.
I will also be doing several other experiments to see if different behaviors make a difference in how FPS degrades over time - magma destroying and atom-smashing have been reported to not fully "destroy" items in memory, so I'm going to try another experimental run with atom-smashing, and one with magma if I can get around to it.
Data:
I have set up my experimental fort. 21 "Sweatshop" workshops are built, and 16 dwarves have arrived. I am not going to start the full experiment until the start of year 2, which will be the forking point between the control and the experiment (so that the initial setup of the fort does not come out different between the two).
Unfortunately, I didn't do anything to stop dwarves from going "On Break", and there are some dwarves that still aren't working in their sweatshops like good zombie laborers. Useless curs! I don't pay them nothing to stand around talking, I pay them nothing to do my precious "do nothing" task forever!
I also forgot to custom-generate my world with no caverns, so there are probably some giant cave spiders lurking around, spitting webs, and doing some slightly random things to FPS. Hopefully, several years of item-creating will outweigh any cave spider webbing, and it will be roughly equal between both the control and the expermimental versions of the fort, anyway, so this shouldn't be too large an impact.
I have had to set my max FPS to 300, and I still manage to have full FPS initially.
However, as soon as the first caravan arrives (which I have built no Trade Depot for), my FPS drops to below 250. Even after leaving, it is at 275. This already starts to confirm the hypothesis, as I have experienced permanent FPS drop for simply having a merchant caravan walk on the map.
I hit the new year, and didn't get all the dwarven immigrants I wanted. I guess I'll just make do with what I have. Only 16 workers total, making and destroying 20 stones repeatedly forever.
I am working on the experimental version first. All regular workshops have their new orders:
FPS is more variable than it really should be - it must be some crundles hopping on and off the map down in the caverns, or some wolves moving around up top. FPS goes down to 220 and then back up to 280 again.
Year 2 caravan has arrived. FPS dipped to 210, occasionally going down to 195.
Start of year 3. FPS remains around 210. FPS seems to go up when I let DF run in the background while I'm typing these things. If I am typing, and I click back, it's back up at 250, but then immediately starts dropping again back down to 210. I guess the rendering of frames takes up some of the FPS.
Year 4. FPS is dipping down to as low as 180 now, but it still springs back up to 260. I guess there are too many crundles down there fighting it out with GCSes, and it's making these FPS readings a little too variable. Hopefully, if I can just keep the simulation running a little longer then the FPS will drop enough that the oscillations from that stuff will be drowned out more by the abuse I'm putting on the data structures.
Ugh... the game paused as one of the merchants apparently went berserk for no apparent reason instead of just sitting on the edge of the map and doing nothing like a good merchant who comes to a fortress that has walled itself in, and has never traded with you before, anyway.
Apparently, the guards had crossbows, the berserking merchant never stood a chance, and was promptly pincushioned with silver bolts. A yak cow also died, and there's now a bunch of useless trade crap sitting on the north end of my map. It's only about 40 items, however, so it shouldn't be too much of a drag on the FPS, considering the thousands of stone I already have.
For some reason, the bookkeeper seems bugged. He's been working nonstop at "updating stockpile records", and has hit legendary long ago, and is flashing purple, but I'm still at lowest precision in my stocks... I've finally gotten it working by unassigning my bookkeeper, unassigning the office, and then reassigning both.
... and the stupid berserk merchant just came back as a violent ghost. I had to make a craftsdwarf workshop to slab the stupid berserker. Amusingly, one of my workers was being attacked by the violent ghost the whole time, and didn't even stop working thanks to the NOEMOTION token. Her blood is splattered around her workshop, but she only seems to have a broken lip, and worked straight through it all.
FPS dropped as low as 150 when the caravan was on the map.
Year 5. Some of the merchants are still on the map for some stupid reason. Apparently, they got into a fight with a local wolverine. They might go berserk and start killing each other again, and then I'll need another slab... *sigh* why can't the other bugs leave me alone while I'm hunting the bug I'm after?
The merchants this year aren't going home, either... Some of them started going "stark raving mad" and attacking their yaks.
I'm building a trade depot now just to see if that stops them from behaving so buggy. Apparently, those stupid diplomats will never leave until they either die or speak to you, and walling them out is not an option (and when I un-walled my fort, I had 3 years worth of diplomats talk to me)... I have another bug report to make...
After un-walling my fort, I actually have regained almost all my FPS. This implies most of my losses in FPS were because of stupid merchant caravan problems in the first place.
I am at the start of year 6, so I have 5 full years under this experimental run.
I'm aborting this run, since I have too many silly things going on that have been mucking up the results. I'm reloading this from the fork again.
I'm going to try going back to the fork point, and restart this whole experiment with creating and destroying more stones at a time, while at the same time, not having my fortress walled up.
I've raised my maximum FPS again to an unreachable 3000 instead of 300. That way there aren't readings that are "off the charts" for FPS anymore. Restarting at the fork, I have an initial FPS of 400.
After letting it run for a game month, it's already down to 300 for some reason, although all I've done is set up a trade depot.
Caravan arrived. Just before it arrived, I was down to 260 FPS, after gradually dropping down from 300. When the caravan arrived and set up shop, it was down to 230 FPS. Then all my dwarves apparently smelled caravans at the trade depot, and half my dwarves decided to go on break all at the same time, and it shot up to 600 FPS. As soon as the caravan left, FPS went up even higher. I'm tapping 650 now.
Now it's year 3 (year 2 of experiment 2). FPS back down to 380, but it shoots up to 550 at times, especially when I leave it in the background to type something.
Year 4. FPS swings between 260 and 600. Mostly stays around 500, but it dips down to 300 or so at the turn of Autumn, but back up to 500 just before the caravans come. 350 while the caravans are here. 250 when they leave. 300 for all of winter. Winter seems to be the laggiest time of year.
Year 5. Game still running around 500 most of the time. Drops to 300 for caravan. Dips just below 180 at times as they get ready to leave.
Year 6. 480 most of the time, but it still swings up to 550. 320 during caravan.
Year 7. I'm only running this now to get 10 years of data. It dips as low as 300 or something occasionally, 200 for parts of the caravan, and then runs back up to 500. The average annual FPS is basically remaining stable.
Now, with year 11, the tenth year of the primary experimental run, I have an average FPS of 300 early in the year, going up to 400 and in the faster summer months, 500 again.
Basically, the run is over, and FPS has remained relative stable with no major degradation over the course of 10 years of playtime. This means my experiment has not reproduced the results that people were reporting earlier.
A poster in another thread named "o_O[WTFace]" suggested something that is worth investigating: I've been using stones, which have no particular data applied to them, and as such, I'm going to try running the experiment again, this time creating goblets instead of stones.
Starting year 2, the game is now flooding with announcements of masterpieces (thanks to me making the entire race legendary masons, and basing the reaction on masonry).
And it's getting really boring... I'm still not doing whatever it is that causes the gradual FPS death of forts that everyone always experiences when they make real forts, because I can't sink FPS below 200, and it goes through most of the same seasonal highs and lows.
Next up, atom-smashing, and seeing if that causes the FPS decay people talk about.