14

So uh... my fort at the moment has around 106 dwarves/petitioned entertainers and 20 visitors. The problem is (and this occurred suddenly) is that the FPS has been reduced to ~4 FPS. This is unplayable for me. Is there any way I can restore the FPS back to at least 20?

  • 1
    DONOT buy a better computer. I built a new gaming PC, just a few days ago, so I could finally get the FPS of our succession game to playable rates. mobo Z170a gaming m7CPU intel i7 quadcore 4.0GHz, GPUGeForce GTX 980Ti, 64GB ram, SSD 500GB, OS WIN 10 home, all drivers up-to-date. Expectantly I fired up DF, loaded succession game. Imagine the ultimate face sag when FPS immediately dropped to 6FPS (same as on my 8-yo PC). – Fnord23 Mar 24 '16 at 9:38
  • 1
    I've read of a corner-case involving non-pet-passable doors and cats. It was something like a cat being trapped, and then repeatedly pathfinding (through the locked door), causing massive FPS drops. If it was instanteous slowdown; try unlocking all doors. @fnord23 New computers will rarely help as DF is not using any multithreading at all. My biggest hope is that Toady will at some point give in and learn multithreaded programming :( It is not too hard to do and there will be tons of things that could run in parallel in DF. – antipattern Mar 24 '16 at 11:45
  • 1
    @antipattern: Multithreading is not hard to learn. Multithreading is hard to get right. Multithreading is mind mindbogglingly difficult to tack into an existing program. – Mooing Duck Apr 13 '16 at 0:53
  • I completely agree with that. What I meant that it is not hard to learn by itself. It might be hard to do it with wide coverage, but there will be some things, such as pathfinding, that could be easily parallelized. In an ideal way, except for the world info, there's no shared state in A* for different entities. Have a setup that first updates the world info, after that number of threads that do pathfinding for all the creatures, and you've kept complexity to a minimum. But I understand it's hard to fit that into legacy code. – antipattern Apr 13 '16 at 11:09
  • Multithreading is a very complex science bordering on black magic that is totally unnecessary if all you want is a performance enhancement. A simple parallel map to compute the pathfinding for the entities instead of a for loop is the only change needed, and would not even look like multi-threaded code. There are libraries for this that make it practically a drop in change. – Steven Armstrong Feb 4 '19 at 23:48
6

Most of this advice comes from the wiki page on improving framerate. Some of it unfortunately requires pre-action, before your current point.

A number of things can impact framerate. Flowing water for example takes a lot of CPU power. Item count can affect it, though number of squares with items in them affects it more. Pathfinding can cause trouble.

I find that creature count is my biggest offender, but I don't generally have large amounts of flowing liquid in my forts.

However changing the structure of your fort with framerates that low is going to be a pain and a half. There are some things you can turn off in configuration files that may help. The important file here is df/data/init/d_init.txt. In this file you can adjust things like the population cap which would let you avoid having too many dwarves in the first place. You can also turn off temperature calculations which can speed up the game some.

Not knowing a huge amount about your setup, I would recommend turning off temperature, at least temporarily, to get enough speed to work with. Be sure to also reduce your population cap. Otherwise your population will just keep growing and slow you back down again.

I would also confine all your animals to walled off pastures or cages and close off unneeded areas to reduce pathfinding slowdowns. If you have any waterfalls or pumped areas, turning them off could also help.

Some people don't like to use what feels like a bug, but quantum stockpiles can help. Geting all the random junk consolidated is supposed to help framerate.

If some of the random items are things you will never want, like XXPig tail sockXX, You can use a Dwarven Atom Smasher to remove them from the game and no longer spend any CPU cycles at all tracking them. This however is going to be a minor improvement at best, unless you have tens of thousands of worn out socks.

Look at the framerate wiki page and see if any of its other ideas apply in your situation.

  • There is a whole lot more you can do if you start planning around framerate before starting the fort. That information is also on the wiki page that I linked to. – Nick Mar 3 '16 at 15:54
  • One thing about choosing an embark site that the wiki doesn't mention is that greater height variance (which can be seen in one of the alternate tab-view modes during site selection) means more z-levels on a map which can be just as CPU intensive as a wider area. – Nick Mar 5 '16 at 3:22
5

Some things can be done:

  • Shut off that dwarven reactor and any sources of moving water
  • Only female animals are useful. Slaughter everything but the females and maybe 1-2 males for breeding
  • For chicks, build a grid of 1x1-rooms with a nest in it, seal each of them with a door
  • For anything grazing, build similar structures, albeit a bit larger. Size depends on creature type unfortunately. Of course, these animals need food and cannot graze inside.
  • Build a dwarven atom smasher and get rid of the junk lying around
  • Make sure that you only dig small corridors, 1 - max 3 spaces wide (and 3 only where there is loads of traffic). Wall off large, unused parts, for example where you mined out for resources. Use the traffic designators, use forbidden for parts that need no maintenance. Use burrows. If your miners only need access to lower levels, restrict them to that. Make burrows as small as possible.

In my experience, the last point has the most significant effect, since the pathfinding needs a lot of CPU time and it will not consider spaces not reachable or outside of the burrows. The key point here is to restrict creatures as much as possible.

And never, ever, embark in a coastal biome. The waves are nice and stuff but you will have died the FPS death even before you arrived.

  • For chicks, build a grid of 1x1-rooms with a nest in it, seal each of them with a door don't tell the DARM! (Dwarven Animal Rights Movement). – Madmenyo Mar 24 '16 at 18:02
  • @MennoGouw The DARM doesn't exist, EETA does for trees though. – noirscape Mar 25 '16 at 11:25
3

The core of the problem is pathfinding. Dwarf fortress uses A* pathfinding with some crude hacks to improve performance. It does not use any fancy tricks like Hierarchical Pathfinding which would reduce the CPU usage by more then 95 percent on long distances. The best thing to do is learn a bit about the A* alghorithm so you know it's pitfalls and keep this in mind when building your fort. But without any coding experience I can imagine this being hard. The wiki has some do's and dont's about ways to design your fortress to help the pathfinder out. The fact remains that the game would get a > 95% performance boost if toady would implement a good indexed hierarchical pathfinder, flocking and perhaps run this on a separate thread (which would probably be really hard to do given the current design choices).

Your issue at hand is very likely that most of your little dwarfs want to go to a far away position or at least a position where the pathfinder needs to check a lot of tiles as candidates for a path. So the first thing you could do is play on smaller maps in both X,Y,Z. Tile size grow exponentially 10x10x10 is just 1000 tiles but 20x20x20 is already 8000 tiles. So playing on a 2x2 area would be a lot faster then a 4x4 area later on in the game.

What you can do right now is assign burrows. Just let a view dwarfs gather those materials outside your fortress. Burrows has the nice side effect that dwarfs assigned to it would never get a task that is outside the burrow. It also narrows down the tiles the pathfinder will check since it should not consider a tile outside the burrow since the dwarf cannot go there.

0

As per the DF Wiki [http://dwarffortresswiki.org/index.php/v0.34:Maximizing_framerate], the more stuff the game has to keep track of, the slower it runs.

Some ways you can improve framerate are:

1) Reduce the size of your embark site. There is a utility called Nanofortress [for Windows] that allows you to do a 1x1 embark. The utility is located at http://www.bay12forums.com/smf/index.php?topic=21601.0 Even if you don't use this, you can reduce your starting embark site to a 2x2 or 3x3 site.

2) The number of items in your fort slows the game. Overproduction of items you don't need, or not destroying and/or gifting these non-need items to passing caravans will slow the game.

3) Flowing water or flowing Magma slows the game. Any volcanos or other magma sources, and any oceans or rivers will slow the game since it calculates where those liquids are moving to. One solution for this problem is to embark on a location with no surface magma or water.

4) Pathfinding slows the game. If you build a fort with multiple possible paths for your dwarves to go from one location to another, the game will check each possible path each time a dwarf needs to travel there. This pathfinding slowness applies to animals as well. If you have had a catsplosion or many other animals wandering around your fortress, that will slow the game. Some solutions to the pathfinding issues are to slaughter excess animals, set a cap on your dwarf population, and close and lock doors to remove possible paths. Also, any caged animals don't need to pathfind, so just cage any excess animals you don't want to get destroy or trade away.

5) Contaminants such as blood splotches on tiles slow the game. You can use the DFhack utility command "clean" to instantly remove all blood from tiles in your embark.

6) Running the game on a faster machine, not running other programs at the same time, and setting the game's CPU priority higher will all speed up the game.

7) The issues listed that involve slowdowns due to the games display of graphics can be reduced by watching the game in a smaller (fewer tiles displayed at a time) window, or setting the display to watch a Z level where all the tiles are still unexplored, such as a level where your dwarves haven't mined out yet. This solution won't help pathfinding slowdowns or slowdowns when the game calculates how fast and where water or magma is flowing to but I have noticed it does speed up FPS by at least 20 when I want time to go by faster in my games.

  • Isn't really much of a useful suggestion, considering I already dug to the magma sea. – noirscape Mar 6 '16 at 20:14
  • @Ev1l0rd you probably have something still undug. Otherwise that is your problem especially on a larger map. The pathfinder would have no problem with tunnels, but with large open area's it will spread out to consider tiles for the path. Anyway, this technique does not increase performance unless you are playing all the way zoomed out. Drawing 20x20 of these small images would not even take a millisecond. Only the tiles in view need to be considered and this should be fast as well. – Madmenyo Mar 24 '16 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.