Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 [3] 4

Author Topic: My Attempt to Eliminate/Minimize the FPS Death (HELP NEEDED!)  (Read 8247 times)

Snaake

  • Bay Watcher
    • View Profile
Re: My Attempt to Eliminate/Minimize the FPS Death (HELP NEEDED!)
« Reply #30 on: April 02, 2014, 03:03:39 pm »

I just doubled my FPS by de-sealing the caverns - I had a vertical shaft to the magma sea sealing off caverns. There were  3 forgotten beasts waiting for the soldiers. Seems they constantly tried to A* into the fortress bringing down the FPS.

This is the sort of circumstantial fps drain that might quick to fix by e.g. only making them check for a path every 1000 or 10000 ticks once they've failed a few times in a row, but then again, that may be trickier than one might think. And as mentioned, Toady does prefer working on new features unless there's something that makes things completely unplayable.
Logged

juxari

  • Bay Watcher
    • View Profile
Re: My Attempt to Eliminate/Minimize the FPS Death (HELP NEEDED!)
« Reply #31 on: April 02, 2014, 03:09:52 pm »

I think it eventually will slow you down. If I remember correctly the game has to keep track of each of those blocks used in the construction. But, with how few things you have to track a few thousand blocks shouldn't be a problem.
Constructions introduce slowdowns from two angles:
1. It has to keep track of the original item (though there is a DFHack plugin which will delete the item and flag the construction as "recreate the item from scratch when you deconstruct it"), which means that general item lookups take slightly longer (it's done via binary search, so you'd only notice significant slowdowns each time the item count in your fortress doubles).

I'm using DFHack but don't know this plugin or command. Is it active by default?
Logged

TDSS02

  • Bay Watcher
    • View Profile
Re: My Attempt to Eliminate/Minimize the FPS Death (HELP NEEDED!)
« Reply #32 on: April 02, 2014, 04:17:35 pm »

Well, im going to put my .02 cents in. I have had multiple 20+ year forts and no lag what so ever. I think fortress design plays a big role. I always try and design my forts for maximum efficiency because of the path finding and how much memory is involved in that. I also took out clothes and atom smash everything not being used. Seems to work great. I haven't played a fort since 34.07 though, i plan on getting back into it as i love this game. Just the way i play it usually takes hours to plan out my fort before i even start digging haha.
Logged
Quote from: piecewise on March 14, 2010, 06:22:02 am
  Dwarf Fortress: Beat children with children.

enizer

  • Bay Watcher
    • View Profile
Re: My Attempt to Eliminate/Minimize the FPS Death (HELP NEEDED!)
« Reply #33 on: April 06, 2014, 04:36:35 am »

Yeah, fortress design plays a big role, and pathfinding collissions will cause lag spikes if lots of dwarves move at once, through tight areas

like a 20z level 1x1 stairway to the caverns, have a fight in the caverns(animal tribe) and suddenly fps drops to a third of its normal the instant i order the civilians to clean up the corpses and loot, and resumes to normal when they are not pathing through that chokepoint
Logged

MDFification

  • Bay Watcher
  • Hammerer at Law
    • View Profile
Re: My Attempt to Eliminate/Minimize the FPS Death (HELP NEEDED!)
« Reply #34 on: April 06, 2014, 06:46:43 am »

If you're willing to download a mod, there's one that would help with FPS a ton. It's called Accelerated DF, and what it does is standardize most materials found in the game, causing an unbelievable rise in FPS (to the point that your FPS cap becomes necessary to stop the fortress from getting too fast to play). While I personally dislike how it standardizes ores and stones and put them back, it's still good stuff for boosting your FPS.

Another good thing to do if FPS gets to slow is use (fastdwarf 2 0) in DFhack, which boosts the speed of all pathfinding (for friendlies, hostiles and neutrals) equally. The only problem is it can't speed up the flow of liquids, minecarts of falling/flying objects, so those will remain slow. I only do this if the fortress gets too slow to play normally.
Logged

xpi0t0s

  • Bay Watcher
    • View Profile
Re: My Attempt to Eliminate/Minimize the FPS Death (HELP NEEDED!)
« Reply #35 on: April 08, 2014, 12:33:11 pm »

Once the game gets too slow to play normally I switch "fastdwarf 1" on.  Sure, this "overpowers" the dorfs, but on the other hand since gobbos only have to so much as fart and 20 dorfs drop dead I think this is a reasonable compromise.  And most of my time is spent waiting for dorfs to do stuff anyway, so to me fastdwarf 1 makes it playable past the first 40 dorfs.
Logged

juxari

  • Bay Watcher
    • View Profile
Re: My Attempt to Eliminate/Minimize the FPS Death (HELP NEEDED!)
« Reply #36 on: April 15, 2014, 09:36:01 am »

I think I'm done with my fort.

It ended up a pretty absurdly huge but still very functional construction. It's about 40 000 constructed blocks big and has around 2 levels of a 3x3 embark site mined empty overall through all the underground z levels of the castle.

My FPS with around 50 dwarfs was 120 - 200 with the computer specs in my OP. I think that's pretty much playable and very good overall considering that my fortress is a really huge castle, 16 z levels to the highest point from ground level, with a sever network and a pretty complex partly automated self-defense systems with magma pools, magma moats and chambers and sealable sniper zones and a very long atom-smashable wagon sized path underground and it's all designed so wagons could in theory enter the fortress even during sieges and the automated defenses would still work against enemy units. The garbage disposal system is also automated with a quantum-atom smasher. Most stockpiles are quantum stockpiles to conserve FPS.

It's all constructed from platinum and admantin blocks and filled with star ruby windows (I decided to make it as absurd as possible since this after all was just a test with cheats to find a functional design), and it's complex machinery (I recall it's provided with around 4 k power) is powered by hundreds of windmills built on top of walls and towers. The sever network provides water to hundreds of wells built on top of one another in dozens of central stairways. There is no flowing water sources (river) to conserve FPS and all water is pumped from an underground sea to the severs. Magma is pumped from the magma sea.

I can post the fortress if anyone would like to check out the result and compare the FPS you personally get with this design.
« Last Edit: April 15, 2014, 09:41:53 am by juxari »
Logged

Veylon

  • Bay Watcher
    • View Profile
Re: My Attempt to Eliminate/Minimize the FPS Death (HELP NEEDED!)
« Reply #37 on: April 16, 2014, 12:32:17 am »

I just doubled my FPS by de-sealing the caverns - I had a vertical shaft to the magma sea sealing off caverns. There were  3 forgotten beasts waiting for the soldiers. Seems they constantly tried to A* into the fortress bringing down the FPS.

This is the sort of circumstantial fps drain that might quick to fix by e.g. only making them check for a path every 1000 or 10000 ticks once they've failed a few times in a row, but then again, that may be trickier than one might think. And as mentioned, Toady does prefer working on new features unless there's something that makes things completely unplayable.
It's even easier if the terrain is broken up into intranavigable regions. The first step of pathfinding should be to see if the starting tile is in the same region as the ending tile. If not, the search can immediately cease without having to spend a zillion processor ticks on the worst case scenario.

Of course, then you have the overhead of checking to see whether or not regions are being split/merged every single time a tile is changed.

So slapping a timer on the thing might be best for now. It can wander randomly for a few weeks before trying again.
Logged
At what point did the suggestion of child sacrifice become the more ethical option?

GavJ

  • Bay Watcher
    • View Profile
Re: My Attempt to Eliminate/Minimize the FPS Death (HELP NEEDED!)
« Reply #38 on: April 16, 2014, 12:35:19 pm »

Pathing is the biggest FPS drain (including liquid pathing, which is easy to avoid). The biggest things you can do to save on creature pathing costs are:

0) Like everyone always says, make wide hallways.

1) Traffic designations, especially outdoors and in twisty maze-like areas. In mazes (like bedroom slums), set the bedrooms to low, and the arteries to high (main hallways) or normal (capillaries). Outdoors, set the whole outdoor region to low, then make directed corridors of normal or high traffic leading toward your fort's front gate, with a little bit of organic branching. The traffic designations outdoors should end up looking like a crayon drawing of a set of lungs when you're done.  If you do a lot of stuff outdoors, this can easily quadruple your FPS singlehandedly.

2) Avoid long hauls in general. It's better to have a metaphorical (or literal) "bucket brigade" than it is to have a bunch of lone dwarves making the whole long trip. Think of the path as a semi-directional "plume" of searching. Plumes can be huge in open areas, and it's easier to plume out behind or to the side of you than into a twisty maze ahead. Whereas two or more small plumes start to more closely resemble a line and add up to less overall area.

To make a bucket brigade situation, you could for instance use overlapping burrows. For instance, outdoorsdwarves cut wood and move it to a 3x3 temporary stockpile right near your main door inside. Then indoorsdwarves with that area also in their burrow shuttle the wood to the larger wood stockpile somewhere deeper in the fortress. This leads to a small fraction of the total pathing that a single trip would take, even if the dwarves have to come from a bedroom or something to get there (if you set your bedroom traffic right), it still will be a huge savings.

Speaking of which
3) Burrows!  Burrows burrows burrows.  .... burrows. You don't need crazy complex burrows with each their own food and booze supply. You can just have the food and booze (and hospital, etc.) be in one burrow that everybody is in, and then add additional burrows for their industries, etc.  Pretty easy actually.

4) NONE of the above things will help you though for invader pathing. To avoid FPS drag from goblins and such, you also want to avoid twisty mazelike trap areas. An example of a TERRIBLE trap for FPS is a long winding back and forth snake of cage traps. An example of a much more efficient FPS trap is a single straight line one tile wide path into your fort, with weapon traps, and then open space on either side with a pool of water or magma below (gobbos get cut up, or if they dodge, they fall off and drown). The pathing from outdoors into your fort through such a trap will be literally an order of magnitude or two faster than the winding hallway trap setup.

And of course have backup plans for your traps, so that you aren't forced to lock out seeking invaders, as they will constantly try to path in, grinding down FPS hugely as they search the entire map for an entrance. When invaders want to get in, you want to LET them get in and deal with them swiftly.

Having a twisty cage trap is fine as a backup for instance ("omigod there's a flying thing!), that normally is bridged off. That way, the infantry will hit your faster FPS trap first, but if they bring something you can't handle yet with efficint traps, at least you can just open the twisty trap and avoid havign them spam pathing outdoors forever.
« Last Edit: April 16, 2014, 01:16:07 pm by GavJ »
Logged
Cauliflower Labs – Geologically realistic world generator devblog

Dwarf fortress in 50 words: You start with seven alcoholic, manic-depressive dwarves. You build a fortress in the wilderness where EVERYTHING tries to kill you, including your own dwarves. Usually, your chief imports are immigrants, beer, and optimism. Your chief exports are misery, limestone violins, forest fires, elf tallow soap, and carved kitten bone.

Nil Eyeglazed

  • Bay Watcher
    • View Profile
Re: My Attempt to Eliminate/Minimize the FPS Death (HELP NEEDED!)
« Reply #39 on: April 18, 2014, 03:27:35 am »

I haven't found pathing to be the major drain reported by so many in this thread.

I have, a couple of times, decided to kill (via cheat) huge swaths of population in an attempt to recover some framerate, but found that framerates remained low.

I found pathfinding to be an issue in exactly one situation-- when experimenting with (now obsolete) undumps and multiple stockpile squares.  This was a situation where multiple dwarves suddenly lost path and tried to path through every single tile on the map to a suddenly inaccessible tile.  (If it had worked like the original job, with the stockpile pathing to the dwarf instead of vice versa, there would have been no detectable hit, with the path rapidly exhausting all possibilities.)
Logged
He he he.  Yeah, it almost looks done...  alas...  those who are in your teens, hold on until your twenties...  those in your twenties, your thirties...  others, cling to life as you are able...<P>It should be pretty fun though.

GavJ

  • Bay Watcher
    • View Profile
Re: My Attempt to Eliminate/Minimize the FPS Death (HELP NEEDED!)
« Reply #40 on: April 21, 2014, 12:53:19 pm »

Perhaps pathfinding doesn't seem significant to you mainly because you already intuitively design forts in a way that is good for the pathfinder? For me this is the case: doing traffic designations etc. only increases pathfinding by 50% or so usually, because it's already built in a reasonable way.

But if you go build a crazy swirly rabbit warren of a fort, the difference becomes much more acute when you designate it, etc. versus not.  You might just never do that.



There does seem to be some sort of unknown factor that just makes it slower almost no matter what you do over time.  Maybe the slow accumulation of traded goods, or dead things whose deaths are kept track of, or worst case: some sort of memory leak that finds its way into the saves, not just the RAM? I don't know.  But with good design, proper management of pathing and atomsmashing thousands of leftover socks, you can usually get GOOD ENOUGH to last so long that you'd just get bored anyway much longer.
Logged
Cauliflower Labs – Geologically realistic world generator devblog

Dwarf fortress in 50 words: You start with seven alcoholic, manic-depressive dwarves. You build a fortress in the wilderness where EVERYTHING tries to kill you, including your own dwarves. Usually, your chief imports are immigrants, beer, and optimism. Your chief exports are misery, limestone violins, forest fires, elf tallow soap, and carved kitten bone.

Krawdad

  • Bay Watcher
    • View Profile
Re: My Attempt to Eliminate/Minimize the FPS Death (HELP NEEDED!)
« Reply #41 on: April 28, 2014, 01:33:35 pm »

I also would recommend Accelerated DF, I use it and don't have a problem with FPS most of the time, whereas I had a few forts succumb to FPS death before I started using it. My design style probably hasn't changed much and isn't that efficient, but I have a 15 year fort right now on a 4x4 map with 240 or so dwarves, tons of items and stone, lots of exposed magma and even some flowing magma, as well as several very large stockpiles (I didn't know that was a bad thing.)

I did recently turn off temperature calculations when the FPS started sagging to a constant 70 ish, and the switch brought it back up to a stable 100. At one point I also had a ton of military dwarves training, mostly all of them sparring non-stop, and I noticed that the FPS would rise significantly whenever they all stopped sparring due to an order. So now I have them only train 6 months out of the year, rotating so that only half are training at once.

I can also confirm that sealed cavern pathfinding takes a toll -- I had four FBs gobbling up resources by being stuck down there for several years before I made a proper entrace.

Not sure if anyone mentioned this yet, but if you do use mass designations, say for stone smoothing, do it in small patches rather than designating a massive rectangle at once. The same probably goes for exploratory mining, for which the dfhack command digexp diag5 all  is very handy (maybe its expdig? I can never remember).
Logged

gritstone

  • Bay Watcher
    • View Profile
Re: My Attempt to Eliminate/Minimize the FPS Death (HELP NEEDED!)
« Reply #42 on: April 28, 2014, 01:34:00 pm »

Pathing is the biggest FPS drain (including liquid pathing, which is easy to avoid). The biggest things you can do to save on creature pathing costs are:

0) Like everyone always says, make wide hallways.
I'd be interested to know why everyone always says that.  From a pathfinding point of view, a corridor one unit wide hallway doesn't strictly require any path length calculations, you just move to the only position available, and that is surely more efficient than a wider hallway.

Quote
1) Traffic designations, especially outdoors and in twisty maze-like areas. In mazes (like bedroom slums), set the bedrooms to low, and the arteries to high (main hallways) or normal (capillaries). Outdoors, set the whole outdoor region to low, then make directed corridors of normal or high traffic leading toward your fort's front gate, with a little bit of organic branching. The traffic designations outdoors should end up looking like a crayon drawing of a set of lungs when you're done.  If you do a lot of stuff outdoors, this can easily quadruple your FPS singlehandedly.
I'm also interested to know why this would work.  I can understand using traffic areas to avoid places you don't want your dwarves to go, but not to reduce pathing costs.  Every step of the path requires the calculations of the path weight of the surrounding positions taking into account the traffic weighting.  Just because it's obvious to us that they could follow some high traffic line we've set out, that doesn't mean the computer can do it without actually checking the path like it normally would.  If anything, it seems to me that forcing them to take anything but the optimal path is actually adding extra calculations.

So what am I missing?
Logged

doublestrafe

  • Bay Watcher
  • [PONY_DEPENDENT]
    • View Profile
Re: My Attempt to Eliminate/Minimize the FPS Death (HELP NEEDED!)
« Reply #43 on: April 28, 2014, 01:51:19 pm »

0) Like everyone always says, make wide hallways.
I'd be interested to know why everyone always says that.  From a pathfinding point of view, a corridor one unit wide hallway doesn't strictly require any path length calculations, you just move to the only position available, and that is surely more efficient than a wider hallway.
I'm no expert in the back end of things, but I'm pretty sure creatures have to repath every time they collide with another creature. A 1-tile hallway ensures huge numbers of these calculations.

Quote
1) Traffic designations, especially outdoors and in twisty maze-like areas. In mazes (like bedroom slums), set the bedrooms to low, and the arteries to high (main hallways) or normal (capillaries). Outdoors, set the whole outdoor region to low, then make directed corridors of normal or high traffic leading toward your fort's front gate, with a little bit of organic branching. The traffic designations outdoors should end up looking like a crayon drawing of a set of lungs when you're done.  If you do a lot of stuff outdoors, this can easily quadruple your FPS singlehandedly.
I'm also interested to know why this would work.  I can understand using traffic areas to avoid places you don't want your dwarves to go, but not to reduce pathing costs.  Every step of the path requires the calculations of the path weight of the surrounding positions taking into account the traffic weighting.  Just because it's obvious to us that they could follow some high traffic line we've set out, that doesn't mean the computer can do it without actually checking the path like it normally would.  If anything, it seems to me that forcing them to take anything but the optimal path is actually adding extra calculations.

So what am I missing?

This seems easier to me. With every iteration of the pathing calculation, the CPU has to check every endpoint of every place the potential path branches off. If a path branches into new, open territory, that's eight brand new endpoints to check next iteration (minus whatever's reached by other new or existing paths). So even if the same restricted tile still has to be checked 25 more times, that's WAY better than 25 more iterations with new branches to check every time.
Logged

GavJ

  • Bay Watcher
    • View Profile
Re: My Attempt to Eliminate/Minimize the FPS Death (HELP NEEDED!)
« Reply #44 on: April 28, 2014, 02:48:59 pm »

Yup. A 3 wide hallway requires 3x the calculations per pathfinding calculation, roughly, for that portion of the path. But if you collide and recalculate 7 times in a hallway, then your total calculations is still much higher in the narrow hallway.

Also, your stuff is just gonna take like 5x longer to haul around, so in addition to FPS, your fortress is going slower for other reasons (they sit there dazed for many ticks after a collision)

Quote
I'm also interested to know why this would work.  I can understand using traffic areas to avoid places you don't want your dwarves to go, but not to reduce pathing costs.  Every step of the path requires the calculations of the path weight of the surrounding positions taking into account the traffic weighting.  Just because it's obvious to us that they could follow some high traffic line we've set out, that doesn't mean the computer can do it without actually checking the path like it normally would.  If anything, it seems to me that forcing them to take anything but the optimal path is actually adding extra calculations.

So what am I missing?
It's a biased flood fill algorithm. I.e. it spreads outward, but faster in the direction of the goal than backward at any point. Low traffic costs will re-bias this along non obvious paths.

So lets say your dwarf needs to backtrack a bit then turn back around in a hallway and go forward to the goal. With no traffic designations, he will search a whole bunch of dead end routes in front of him and it will waste a bunch of calculations to eventually slowly creep backward and find the backtrack route.  But if you have the dead end rooms as high traffic and the main corridor behind him as low, then the algorithm will flood backward much faster and calculate those first, opposite of normal. And then it will hit the goal a lot faster, and terminate before it ever got around to checking all those dead end rooms ahead.

Think of it sort of like a prairie fire in the wind, the wind being the  direction of the goal.  If it has to burn backward to cross a bridge and get around the other side, it will take forever and half the region will burn before it gets there, because it only creeps slowly against the wind.  But if you doused a path back and across the bridge in kerosene for it, it will get to your destination before almost anything else.
Logged
Cauliflower Labs – Geologically realistic world generator devblog

Dwarf fortress in 50 words: You start with seven alcoholic, manic-depressive dwarves. You build a fortress in the wilderness where EVERYTHING tries to kill you, including your own dwarves. Usually, your chief imports are immigrants, beer, and optimism. Your chief exports are misery, limestone violins, forest fires, elf tallow soap, and carved kitten bone.
Pages: 1 2 [3] 4