v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

Difference between revisions of "Maximizing framerate"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
(update)
Line 1: Line 1:
{{Migrated_article}}
+
{{quality|Fine}}
{{quality|unrated}}
 
 
{{av}}
 
{{av}}
  
Line 12: Line 11:
 
===Without Game Alterations===
 
===Without Game Alterations===
 
Fortress design is specific ways of building and planning, game setting changes are changes mostly in the init and init_d files that don't actually change how the game plays out.
 
Fortress design is specific ways of building and planning, game setting changes are changes mostly in the init and init_d files that don't actually change how the game plays out.
 +
 +
====World Generation====
 +
* Larger worlds require more background processing to update.
 +
* Longer histories require more memory and storage space for historical figures and events.
 +
* Reducing the number of civilizations, sites, and beasts can limit the resources spent updating the rest of the world.
 +
* [[Caverns]] can be a FPS hog due to [[pathfinding]] and how complex they can be. Creatures will repeatedly try to path into your fort from a cavern. Sometimes even [[Trading#Caravans|trading caravans]] will try to path out of your fort underground.
 +
** Adjusting the [[Advanced_world_generation#Cavern_Layer_Number|cavern layer number]] in [[advanced world generation]] parameters can reduce the number [[cavern]] layers (default 3). However, this will restrict access to subterranean plants, creatures, and [[megabeasts]]. You need at least 1 cavern layer to get underground [[crop|plants]], 2 caverns to get all the underground [[tree]]s, and 3 caverns to get all the underground [[animal]]s.
 +
** Similarly, one could adjust [[Advanced_world_generation#Layer_Openness_Min.2FMax|Layer Openness]] and [[Advanced_world_generation#Layer_Passage_Density_Min.2FMax|Layer Passage Density]] in [[advanced world generation]] to turn caverns into wide, open expanses instead of complex mazes that have to be pathed through. However, there is some evidence that excessively open caverns cause performance issues as well.[http://www.bay12forums.com/smf/index.php?topic=104643.msg3096896#msg3096896]
  
 
====Fortress Design====
 
====Fortress Design====
 
* Larger embark sites dramatically increase the amount of terrain which DF needs to keep track of and path through.
 
* Larger embark sites dramatically increase the amount of terrain which DF needs to keep track of and path through.
 
** Reducing the size of your embark site from the default 4x4 squares to 3x3 or even 2x2 will have an enormous impact on FPS.  Keep in mind that a 2x2 embark is only 25% of the size of a 4x4.
 
** Reducing the size of your embark site from the default 4x4 squares to 3x3 or even 2x2 will have an enormous impact on FPS.  Keep in mind that a 2x2 embark is only 25% of the size of a 4x4.
** World size matters the most and reducing the number of cavern layers (default of 3) will help. You need at least 1 cavern layer to get underground [[crop|plants]], and 2 caverns to get all the underground [[tree]]s.
+
 
 +
* Multi-tile trees are a potential source of lag.  
 +
** Choosing an embark location that only grows trees on one or two squares can improve performance.
 +
 
 
* Fewer items inside a fort means fewer items to be [[stockpile]]d, checked for [[wear]], and so on and so forth.
 
* Fewer items inside a fort means fewer items to be [[stockpile]]d, checked for [[wear]], and so on and so forth.
 
** The obvious solution is not to generate so many items in the first place. Don't build such large [[Farming|farm plot]]s and don't go overboard with multiple [[Workshop|workshops]] constantly queued or set on perpetual repeat.
 
** The obvious solution is not to generate so many items in the first place. Don't build such large [[Farming|farm plot]]s and don't go overboard with multiple [[Workshop|workshops]] constantly queued or set on perpetual repeat.
** Checking for clothing [[wear]] and unhappy [[thoughts]] could still have some impact on FPS. (Research is needed.) As of [[Release information/0.34.11|0.34.11]], armor counts for missing clothing thoughts. So dwarves can wear armor instead of clothes or going naked. If nothing else, dumping excess/worn out clothing may help FPS on an old fortress.
+
** Checking for clothing [[wear]] and unhappy [[thoughts]] could still have some impact on FPS. (Research is needed.) Armor counts for missing clothing thoughts, so dwarves can wear armor instead of clothes or going naked. If nothing else, dumping excess/worn out clothing may help FPS on an old fortress.
 
** Use a [[Dwarven Atom Smasher]] to remove items, or donate them to [[Trading|passing caravans]] to be taken away.
 
** Use a [[Dwarven Atom Smasher]] to remove items, or donate them to [[Trading|passing caravans]] to be taken away.
 
** [[Exploit#Quantum_stockpiles|Quantum stockpiles]] can [http://www.bay12forums.com/smf/index.php?topic=92241.msg3276117#msg3276117 reportedly] improve game speed.
 
** [[Exploit#Quantum_stockpiles|Quantum stockpiles]] can [http://www.bay12forums.com/smf/index.php?topic=92241.msg3276117#msg3276117 reportedly] improve game speed.
Line 60: Line 70:
  
 
====Game Settings====
 
====Game Settings====
* Consider running an older version of DF. While lacking features, 40d or a [[version]] of v0.31 ''may'' run faster than 2012. *Disputed* (See [http://www.bay12forums.com/smf/index.php?topic=122441.0 this topic] for a debate over FPS on 2012 vs v0.31, game settings, and other FPS issues.)
+
* Consider running an older version of DF. While lacking features, 40d, v0.31, or v0.34 ''may'' run faster than 2014. *Disputed* (See [http://www.bay12forums.com/smf/index.php?topic=122441.0 this topic] for a debate over FPS on 2012 vs v0.31, game settings, and other FPS issues.)
 
* [[Temperature]] calculations place a significant load on the processor.
 
* [[Temperature]] calculations place a significant load on the processor.
 
** Disabling them, using the settings in d_init.txt, will speed things up.
 
** Disabling them, using the settings in d_init.txt, will speed things up.
 
** Without temperature calculations, [[obsidian farming]] becomes unusable; as the tiles never cool down, dwarves refuse to step on the obsidian floor, preventing the access of hauling dwarves.{{bug|6033}} You can re-enable temperature occasionally to allow tile temperatures to normalize.
 
** Without temperature calculations, [[obsidian farming]] becomes unusable; as the tiles never cool down, dwarves refuse to step on the obsidian floor, preventing the access of hauling dwarves.{{bug|6033}} You can re-enable temperature occasionally to allow tile temperatures to normalize.
** Multiple users have reported an fps increase of 100% or better when disabling temperature calculations[http://www.bay12forums.com/smf/index.php?topic=86761.msg2352509#msg2352509].
+
** Multiple users have reported an fps increase of 100% or better when disabling temperature calculations (in previous versions)[http://www.bay12forums.com/smf/index.php?topic=86761.msg2352509#msg2352509].
 
* Disabling [[weather]] ''might'' speed things up as well.
 
* Disabling [[weather]] ''might'' speed things up as well.
 
** But then rain won't refill [[murky pool]]s, clean contaminants, kill dwarves, etc.
 
** But then rain won't refill [[murky pool]]s, clean contaminants, kill dwarves, etc.
 
* Each dwarf needs to keep track of where he's going.
 
* Each dwarf needs to keep track of where he's going.
** Limit the number of dwarves by setting the population cap.
+
** Limit the number of dwarves by setting a [[immigration|population cap]].
 
* Each animal needs to pathfind, too.
 
* Each animal needs to pathfind, too.
 
** Tame animals can be put into [[cage]]s, keeping them from having anywhere to go.  Or you can butcher them.
 
** Tame animals can be put into [[cage]]s, keeping them from having anywhere to go.  Or you can butcher them.
Line 74: Line 84:
 
* Invaders also need to pathfind.
 
* Invaders also need to pathfind.
 
** Turn off invasions using the option in [[D_init.txt]]. Or you can kill them all.
 
** Turn off invasions using the option in [[D_init.txt]]. Or you can kill them all.
* [[Caverns]] can be a FPS hog due to [[pathfinding]] and how complex they can be. Creatures may try to path into your fort from a cavern. Sometimes even [[Trading#Caravans|trading caravans]] will try to path to your fort underground.
+
* You can disable cavern layers in [[advanced world generation]]. Without caverns you will have far fewer critters and threats pathfinding through winding passages. Unfortunately, you also lose underground [[plant]]s and [[tree]]s.
** Adjusting the [[Advanced_world_generation#Cavern_Layer_Number|cavern layer number]] in [[advanced world generation]] parameters can reduce or disable the number [[cavern]] layers during [[world generation]]. However, this may restrict access to subterranean plants, creatures, and [[megabeasts]].
 
** Similarly, one could adjust [[Advanced_world_generation#Layer_Openness_Min.2FMax|Layer Openness]] and [[Advanced_world_generation#Layer_Passage_Density_Min.2FMax|Layer Passage Density]] in [[advanced world generation]] to turn caverns into wide, open expanses instead of complex mazes that have to be pathed through. However, there is some evidence that excessively open caverns cause performance issues as well.[http://www.bay12forums.com/smf/index.php?topic=104643.msg3096896#msg3096896]
 
  
 
====Mods and Utilities====
 
====Mods and Utilities====
* Accumulations of [[contaminant]]s can decrease FPS and they are still somewhat buggy. (See {{bug|296}} and {{bug|3270}}.)
+
* Accumulations of [[contaminant]]s can decrease FPS and they are somewhat buggy. (See {{bug|296}} and {{bug|3270}}.)
 
** Sometimes contaminants are widespread or difficult to reach such that relying on the usual [[cleaning]] methods would be impractical or impossible. Or the player make lack the patience to deal with it that way. Some opt to use the "clean" and "spotclean" commands in the [[Utility:DFHack|DFhack]] utility to clear contaminants.
 
** Sometimes contaminants are widespread or difficult to reach such that relying on the usual [[cleaning]] methods would be impractical or impossible. Or the player make lack the patience to deal with it that way. Some opt to use the "clean" and "spotclean" commands in the [[Utility:DFHack|DFhack]] utility to clear contaminants.
 +
 
* Constantly-growing piles of cast-off clothes and checking for clothing [[wear]] and unhappy [[thoughts]] can impact FPS.
 
* Constantly-growing piles of cast-off clothes and checking for clothing [[wear]] and unhappy [[thoughts]] can impact FPS.
 
** One could [[Modding_guide|modify]] clothing to prevent [[wear]]. (This would require a [[DF2012:World_generation|world regen]].) This can be done by adding an [[DF2012:Armor_token|ARMORLEVEL:1]] token. Aside from a possible FPS gain, this has other benefits as well. This fix is part of the [[DF2012:List_of_mods#Modest_Mod|Modest Mod]] as an optional "Eternal Fashion module". It might also be found in other mods which are based around Modest Mod. (Search the [http://dffd.wimbli.com/ DFFD] for "Modest".) Also, [[DF2012:List_of_mods#Masterwork_Dwarf_Fortress_.28MDF.29|Masterwork Dwarf Fortress]] allows the creation of metal clothing.
 
** One could [[Modding_guide|modify]] clothing to prevent [[wear]]. (This would require a [[DF2012:World_generation|world regen]].) This can be done by adding an [[DF2012:Armor_token|ARMORLEVEL:1]] token. Aside from a possible FPS gain, this has other benefits as well. This fix is part of the [[DF2012:List_of_mods#Modest_Mod|Modest Mod]] as an optional "Eternal Fashion module". It might also be found in other mods which are based around Modest Mod. (Search the [http://dffd.wimbli.com/ DFFD] for "Modest".) Also, [[DF2012:List_of_mods#Masterwork_Dwarf_Fortress_.28MDF.29|Masterwork Dwarf Fortress]] allows the creation of metal clothing.
 +
 +
* Some mods have been created specifically to improve performance. They often reduce and standardize materials (like leather and bone) and may reduce the types of clothing available to control item count (especially for invaders).
 +
 +
** [http://www.bay12forums.com/smf/index.php?topic=117954.0 Accelerated Dwarf Fortress] for v0.34.11
 +
** [http://www.bay12forums.com/smf/index.php?topic=141715.0 Modest Accelerated Mash] for v0.40.x
  
 
==DFHack commands==
 
==DFHack commands==

Revision as of 18:19, 14 November 2014

This article is about the current version of DF.
Note that some content may still need to be updated.

A picture of Dwarf Fortress with Frames Per Second displayed.

Framerate is used in Dwarf Fortress to measure the speed at which the game is running. It is measured in "frames per second", or FPS for short. To check your FPS in Dwarf Fortress, simply change [FPS:NO] to [FPS:YES] in init.txt, and your FPS will be displayed on the top row of the screen. The first number is the current frame rate, while the number in parentheses is the current graphical frame refresh rate.

Increasing your Framerate

In general, the more stuff the game has to keep track of, the slower the game will run. So, reducing the amount of stuff active keeps your game running fast. The below lists separate ways to improve FPS into two categories: things that don't change the game in any fundamental way, and things that do.

Without Game Alterations

Fortress design is specific ways of building and planning, game setting changes are changes mostly in the init and init_d files that don't actually change how the game plays out.

World Generation

  • Larger worlds require more background processing to update.
  • Longer histories require more memory and storage space for historical figures and events.
  • Reducing the number of civilizations, sites, and beasts can limit the resources spent updating the rest of the world.
  • Caverns can be a FPS hog due to pathfinding and how complex they can be. Creatures will repeatedly try to path into your fort from a cavern. Sometimes even trading caravans will try to path out of your fort underground.

Fortress Design

  • Larger embark sites dramatically increase the amount of terrain which DF needs to keep track of and path through.
    • Reducing the size of your embark site from the default 4x4 squares to 3x3 or even 2x2 will have an enormous impact on FPS. Keep in mind that a 2x2 embark is only 25% of the size of a 4x4.
  • Multi-tile trees are a potential source of lag.
    • Choosing an embark location that only grows trees on one or two squares can improve performance.
  • Fewer items inside a fort means fewer items to be stockpiled, checked for wear, and so on and so forth.
    • The obvious solution is not to generate so many items in the first place. Don't build such large farm plots and don't go overboard with multiple workshops constantly queued or set on perpetual repeat.
    • Checking for clothing wear and unhappy thoughts could still have some impact on FPS. (Research is needed.) Armor counts for missing clothing thoughts, so dwarves can wear armor instead of clothes or going naked. If nothing else, dumping excess/worn out clothing may help FPS on an old fortress.
    • Use a Dwarven Atom Smasher to remove items, or donate them to passing caravans to be taken away.
    • Quantum stockpiles can reportedly improve game speed.
    • The quantity of items in any particular stack doesn't effect framerate so much as the number of stacks in general, due to the resultant impact on hauling, stockpiles, pathfinding and other CPU-intensive tasks. The research done on the Undump Engine and Micha's experimental fort demonstrate very FPS efficient solutions, while avoiding traditional stockpiles and the use of barrels and bins.
  • Flowing water slows the game down.
    • Don't build mist generators, pump stacks, or other major water-moving projects. If you do build them, build a way to switch them off.
    • Don't embark on a river or ocean. Rivers aren't too bad in their natural state, because the game only needs to calculate at where the water enters and where the water leaves, more-or-less skipping the water in between. Then you start damming them and pumping water out, and it gets worse.
    • Aquifers don't impose load until you start digging around in them.
    • Dwarven water reactors also slow down the game, often significantly.
  • Proper use of traffic designations will help.
    • Setting corridors to "high" traffic, and dead-end workshop rooms next to them to "low" traffic, means the pathfinder algorithm will search more quickly along the corridor, and waste less time searching in the rooms.
    • Changing the normal traffic weight to 1 in d_init.txt will optimize the pathfinder at the cost of High traffic zones not making a difference (source)
  • Reducing the area which the pathfinder algorithm has to search lets the game run faster.
    • The obvious solution is to not dig out quite so much of the ground.
    • Some careful fort planning and design can cut down on pathfinding with shorter trips.
    • A single, central staircase is fine if workshops are never far from the staircase; but if you have long hallways, you can increase performance by linking them across z-levels.
    • Closing off unused areas with raised bridges and locked doors can help.
    • Caverns are probably the worst offender for pathfinding in irrelevant areas. So keep them closed off.
  • Contaminants can accumulate on the ground and on dwarves and creatures. Especially for old forts, this can impact FPS. There is a bug (Bug:296) which makes contaminants continuously multiply and another (Bug:3270) which prevents blood from ever disappearing.
    • If the contaminants are outside, isolate the area and let rain slowly wash it away. Pets can be kept out with a pen/pasture or a pit. Similarly, setting the traffic designation to restricted and/or assigning Activity Zones strategically may keep dwarves away.
    • Add in some in-fortress means of cleaning dwarves and pets. The Dwarven Bathtub is one example. And make sure you have the cleaning labor enabled. Details of these and other suggestions can be found on the cleaning page.
  • Encountering HFS will dramatically reduce FPS AFTER you seal the breach (Bug:1340). Either avoid doing so or use the work around posted in the bug report.

Game Settings

  • G_FPS is a setting in the init.txt file. It controls how often Dwarf Fortress redraws the screen. It also controls how often the game checks for keyboard or mouse input.
    • Reducing G_FPS can speed up the rest of the game. The default choice of 50 works well, but many people reduce it down to 20 with no ill effect.
    • Reducing G_FPS too far can make the game unresponsive and glitchy. Some people can cope with 5; most cannot.
  • PRINT_MODE is another init setting. It controls the method Dwarf Fortress uses to draw the screen.
    • More advanced methods allow DF to make more use of OpenGL features and therefore your graphics card. STANDARD and VBO are good starting points.
    • More advanced methods may still have bugs. 2D is more likely to be reliable.
  • Using creature graphics may reduce FPS. (Using a custom ASCII tileset should have no effect)
  • PRIORITY represents how much importance the game is given when it makes a request of the CPU. From init.txt:
    • "Change this to make the dwarfort.exe process have a different priority. From highest to lowest, the options are REALTIME, HIGH, ABOVE_NORMAL, NORMAL, BELOW_NORMAL and IDLE."
    • While it's best to run DF with no other programs in the background if FPS is an issue, giving the priority a bump or two can help speed things up regardless.
  • TEXTURE_PARAM controls how the graphics are displayed, specifically how the color value of each pixel is smoothed. It is LINEAR by default. Turning this off gives the CPU one less thing to do, though the improvement in performance is so far unquantified.
    • From init.txt: "Change this to NEAREST if you want the texture values to use the nearest pixel without averaging. Change this to LINEAR if you want the texture values to be averaged over the adjacent pixels."

With Game Alterations

All changes in this area have some effect on the game itself, use at your own discretion.

Game Settings

  • Consider running an older version of DF. While lacking features, 40d, v0.31, or v0.34 may run faster than 2014. *Disputed* (See this topic for a debate over FPS on 2012 vs v0.31, game settings, and other FPS issues.)
  • Temperature calculations place a significant load on the processor.
    • Disabling them, using the settings in d_init.txt, will speed things up.
    • Without temperature calculations, obsidian farming becomes unusable; as the tiles never cool down, dwarves refuse to step on the obsidian floor, preventing the access of hauling dwarves.Bug:6033 You can re-enable temperature occasionally to allow tile temperatures to normalize.
    • Multiple users have reported an fps increase of 100% or better when disabling temperature calculations (in previous versions)[2].
  • Disabling weather might speed things up as well.
    • But then rain won't refill murky pools, clean contaminants, kill dwarves, etc.
  • Each dwarf needs to keep track of where he's going.
  • Each animal needs to pathfind, too.
    • Tame animals can be put into cages, keeping them from having anywhere to go. Or you can butcher them.
    • Avoid pet-impassible doors; animals will stand at the door and continuously path through it.Bug:797
  • Invaders also need to pathfind.
    • Turn off invasions using the option in D_init.txt. Or you can kill them all.
  • You can disable cavern layers in advanced world generation. Without caverns you will have far fewer critters and threats pathfinding through winding passages. Unfortunately, you also lose underground plants and trees.

Mods and Utilities

  • Accumulations of contaminants can decrease FPS and they are somewhat buggy. (See Bug:296 and Bug:3270.)
    • Sometimes contaminants are widespread or difficult to reach such that relying on the usual cleaning methods would be impractical or impossible. Or the player make lack the patience to deal with it that way. Some opt to use the "clean" and "spotclean" commands in the DFhack utility to clear contaminants.
  • Constantly-growing piles of cast-off clothes and checking for clothing wear and unhappy thoughts can impact FPS.
    • One could modify clothing to prevent wear. (This would require a world regen.) This can be done by adding an ARMORLEVEL:1 token. Aside from a possible FPS gain, this has other benefits as well. This fix is part of the Modest Mod as an optional "Eternal Fashion module". It might also be found in other mods which are based around Modest Mod. (Search the DFFD for "Modest".) Also, Masterwork Dwarf Fortress allows the creation of metal clothing.
  • Some mods have been created specifically to improve performance. They often reduce and standardize materials (like leather and bone) and may reduce the types of clothing available to control item count (especially for invaders).

DFHack commands

A list of DFHack commands that can help with your framerate by fixing bugs and reducing items.

  • autodump Useful for mass dumping or destroying items. Use help autodump for options.
  • cleanowned Confiscates and dumps garbage owned by dwarfs. Use help cleanowned for options. Can cause unhappy thoughts if no replacement clothing is available.
  • clean and spotclean Removes contaminants from tiles/units/items or one tile. Bug:296Bug:1750Bug:3270 Use help clean for options.
  • flows Counts map blocks with flowing liquids, which slow the game down.
  • tweak fast-heat Further improves temperature update performance.
  • fastdwarf Causes dwarves to teleport to their destinations. Run "help fastdwarf" for more information.

Mac OS X Specific

Spotlight indexes files on your mac. Since DF constantly changes files, spotlight will keep indexing them using 60-70% of your CPU. Exclude DF in system preferences: spotlight's privacy settings (by dragging the save folder into the list or pressing the + button) and you can get a factor of two in FPS. This can easily provide benefits of over 30 FPS, even on multicore computers that do not need to worry about CPU. This is due to the fact that DF is not multi-threaded in any significant way.

Note that excluding the save folder from Spotlight means you can't use Spotlight or Finder to search through the raw files. If you need to for some reason, you can use "find" from the command line for this.