Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Optimizations for large numbers of different items on the map  (Read 1969 times)

Dorfimedes

  • Bay Watcher
  • The Human Baby is caught in a burst of flames!
    • View Profile

So, I was reading the Masterwork DF thread and some people have noticed that having a large number of differing items on the map can cause FPS issues. Modding fixes this at the expense of variety, but is there any way we could have our cake and eat it too? Besides the interface problems it causes (which could probably be solved be giving things like leather generic groupings in the menus), I really like the added flavor of knowing exactly what creature a particular byproduct was made from and having a difference between high boots and low boots for example. I'm a firm believer that it's "the little things" and attention to detail that make DF truly something else.

Surely there's a way to make DF handle all these items better? I reckon it would be several orders easier to solve than pathfinding optimizations (although I might not know any better), yet I don't see anything like this on the eternal suggestions list. I believe that items are the silent killer of your fort's framerate and it deserves a little extra investigation, and if there's a clear problem, a remedy. What do you think?
Logged
"It seems that perfection is reached not when there is nothing left to add, but when there is nothing left to take away." -Someone who has never played DF.

The Human Baby has died in the heat.

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Optimizations for large numbers of different items on the map
« Reply #1 on: May 10, 2012, 12:57:26 pm »

I don't know about large numbers of different types of items adds lag to the game: Can you post a link to somewhere that science has been done on that? 

I can say, however, that the game lags significantly with large numbers of items, period, and it's apparently partly because of simply being a giant vector for items. 

Unless there is something that mandates items be sequential in memory because DF is pulling some sort of memory trick, which may be possible, but not terribly likely, then a dequeue or some other form of container that is designed to handle larger numbers of items without causing severe speed loss would boost performance in large-item-count forts without having to sacrifice functionality. 
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

Dorfimedes

  • Bay Watcher
  • The Human Baby is caught in a burst of flames!
    • View Profile
Re: Optimizations for large numbers of different items on the map
« Reply #2 on: May 10, 2012, 01:17:40 pm »

Hey, I just read your thread, Kohaku! I'm eagerly awaiting more tests on this, because it doesn't look like anyone else is doing it currently. That variety causes lag is an assumption on my part that I made based on what others have said (some comments in the DF masterwork thread as mentioned earlier), and good old-fashioned hunches and intuition. The lag produced by caravans is pretty significant even with forts that have a ton of stone lying around, which makes me think that the variety of goods they bring and their clothing are to blame. Gods, the clothing! There's a bazillion different types of plant fibers and leather that can make up many different types of clothing, and that's not even taking armor into account.

Something else that bears mentioning, is when I reclaimed my two-year old fort due to a tantrum spiral. I noticed a permanent drop in FPS, bringing me down to 50, from 80-100, which is nothing to sneeze at. I don't seem to remember the frame rate being that low before reclaiming and I'm getting better numbers with a similar number of dwaves now. And this was just with my starting seven dwarves.

So, what I did was use my book keeper to mark all the crap strewn around the wilderness (there was a LOT of clothing and equipment from the previous fifty-dwarf tantrum spiral) for dumping and destroyed it all with DF Hack. I estimate about 600-700 items were removed in total, and the change was immediately noticeable, I gained about 30 FPS right off the bat. This is a little puzzling since my fort has produced about 2000 units of stone plus other goods, yet it didn't seem to have such a drastic effect on framerate.

I think this is either an issue of variety, or perhaps the items being out of stockpiles and strewn in far-off regions of the map. I can't say which, but you would certainly be the one to test this if you felt like doing it; the conditions this all happened in were far from a controlled environment and I can't fully remember the exact numbers and details.
Logged
"It seems that perfection is reached not when there is nothing left to add, but when there is nothing left to take away." -Someone who has never played DF.

The Human Baby has died in the heat.

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Optimizations for large numbers of different items on the map
« Reply #3 on: May 10, 2012, 02:33:56 pm »

Caravans have other lag-causing problems.  I caused lag just locking the diplomat out, presumably because he kept trying to path to my expedition leader.

There shouldn't be anything in particular about large numbers of types of items in the game that should cause lag over and above what large numbers of items themselves cause - at least, nothing I can think of from a programming perspective.

In fact, most of those plant fiber types and stones should already be in your fortress, so they wouldn't be expanding much of anything, anyway.

I'll try to specifically test large numbers of material types next time I go, however...

With that said, individual toes, for example, will have plenty of problems - they will have thinner skin on a toe than upon a torso, for example, because skin is relsized, so a body part with ten times the overall size will also have ten times thicker skin.  Attacks that shouldn't be blocked by a single body part, like a hammer smashing a finger should have the chance to keep on going straight through the hand and into the torso, depending on body position and attack angle. 

Even without that, multiple body parts can take up memory and chew up processor time checking, so there could certainly be a reduction in FPS drag for having less toes and teeth.
« Last Edit: May 10, 2012, 02:38:30 pm by NW_Kohaku »
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

thisisjimmy

  • Bay Watcher
    • View Profile
Re: Optimizations for large numbers of different items on the map
« Reply #4 on: May 10, 2012, 05:44:47 pm »

Perhaps the most important rule of optimization is never assume, always measure.

Quote
"Bottlenecks occur in surprising places, so don't try to second guess and put in a speed hack until you have proven that's where the bottleneck is." — Rob Pike

In addition, you must be careful in how you measure this because there are many variables that need to be properly controlled.  For example, if silk socks were slowing down performance and your mod with reduced variety didn't have silk socks, you could falsely conclude that variety hurts performance.
Logged

Andeerz

  • Bay Watcher
  • ...likes cows for their haunting moos.
    • View Profile
Re: Optimizations for large numbers of different items on the map
« Reply #5 on: May 10, 2012, 05:58:47 pm »

Ah, !!SCIENCE!!

Also, Dorfimedes... your avatar animation is supremely disturbing...
Logged

bluea

  • Bay Watcher
    • View Profile
Re: Optimizations for large numbers of different items on the map
« Reply #6 on: May 10, 2012, 06:48:57 pm »

I seem to remember !!Science!! about this, but my searching isn't turning up the thread I wanted.

I do get Simplification Mod Thread, and Intensify Mod.

But the science I seem to recall basically completely nuked all non-economic stone into gabbro. Not just -mined- stone, but every single tile on the map that was of any other stone type just flat-out became gabbro. And there was an FPS improvement.

Can't say that that is still true (this was several years ago at this point!).
And, have no !!Proof!!
So, ymmv.
Logged

NTJedi

  • Bay Watcher
    • View Profile
Re: Optimizations for large numbers of different items on the map
« Reply #7 on: May 11, 2012, 01:51:08 pm »

I really like the added flavor of knowing exactly what creature a particular byproduct was made from and having a difference between high boots and low boots for example. I'm a firm believer that it's "the little things" and attention to detail that make DF truly something else.
The difference between high boots and low boots are worthwhile because each provide different types of protection and thus more gameplay depth.  Now besides the financial value there is no difference between rat leather cloak and cave dragon leather cloak so its wasted resources on our computers and also insults what should be the better quality leathers.  I wonder how many gamers have walked away from dwarf fortress simply because they've placed lots of time and love into a fort only to have it die from FPS.  So while I agree the game should have the "added flavor of what creature a particular byproduct was made from"...  these should ONLY exist if they provide actual gameplay depth such as the differences between high boots and low boots OR shields and bucklers.
On the same note I wouldn't want the game to include wagons having small wheels and large wheels unless they provided some actual gameplay differences.  If they're going to be exactly the same then JUST CALL THEM WHEELS.
Logged

GreatWyrmGold

  • Bay Watcher
  • Sane, by the local standards.
    • View Profile
Re: Optimizations for large numbers of different items on the map
« Reply #8 on: May 11, 2012, 08:29:00 pm »

Also, Dorfimedes... your avatar animation is supremely disturbing...

Geez, I didn't even notice until you pointed it out...
Logged
Sig
Are you a GM with players who haven't posted? TheDelinquent Players Help will have Bay12 give you an action!
[GreatWyrmGold] gets a little crown. May it forever be his mark of Cain; let no one argue pointless subjects with him lest they receive the same.

NTJedi

  • Bay Watcher
    • View Profile
Re: Optimizations for large numbers of different items on the map
« Reply #9 on: May 11, 2012, 10:04:39 pm »

Also, Dorfimedes... your avatar animation is supremely disturbing...
I think it's sort of referencing what happens to many babies within dwarf fortress  OR  he's just one dark sinister fella.
Logged