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
(Fix fps counter instructions.)
("Items do not" what? Probably missing sentence.)
Line 29: Line 29:
  
 
* Line-of-sight calculations, even after optimizations in v50.05, are the slowest part of the game by a wide margin. This is O(n^2) by nature, so the only way to truly reduce it is to reduce the amount of units. That said, there are still ways you can reduce the issues.
 
* Line-of-sight calculations, even after optimizations in v50.05, are the slowest part of the game by a wide margin. This is O(n^2) by nature, so the only way to truly reduce it is to reduce the amount of units. That said, there are still ways you can reduce the issues.
** Keep your dwarves spread far apart--units who are more than 26 units away from a given unit in '''any direction''' are not considered for line-of-sight calculations.
+
** Keep your dwarves spread far apart--units who are more than 26 units away from a given unit in '''any direction''' are not considered for line-of-sight calculations.
** Avoid having only one meeting area that has hundreds of dwarves in it.
+
** Avoid having only one meeting area that has hundreds of dwarves in it.
** Try to break line-of-sight in various places to keep your dwarves from asking "friend or foe?" too often.
+
** Try to break line-of-sight in various places to keep your dwarves from asking "friend or foe?" too often.
  
 
* Fewer items inside a fort means fewer items checked for temperature, which is the only major performance issue items cause.
 
* Fewer items inside a fort means fewer items checked for temperature, which is the only major performance issue items cause.
 
** 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.
 
** 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]] only help with game speed when you're looking at your stockpiles all the time. Items do not  
+
** [[Exploit#Quantum_stockpiles|Quantum stockpiles]] only help with game speed when you're looking at your stockpiles all the time. <!--Items do not --!>
 
** The quantity of items in any particular stack doesn't affect 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 [http://www.bay12forums.com/smf/index.php?topic=92241.0 Undump Engine] and [http://www.bay12forums.com/smf/index.php?topic=109319.0 Micha's experimental fort] demonstrate very FPS efficient solutions, while avoiding traditional stockpiles and the use of [[barrel]]s and [[bin]]s.
 
** The quantity of items in any particular stack doesn't affect 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 [http://www.bay12forums.com/smf/index.php?topic=92241.0 Undump Engine] and [http://www.bay12forums.com/smf/index.php?topic=109319.0 Micha's experimental fort] demonstrate very FPS efficient solutions, while avoiding traditional stockpiles and the use of [[barrel]]s and [[bin]]s.
 
** That said, [http://www.bay12forums.com/smf/index.php?topic=104643.msg3094753#msg3094753 total quantity of items does matter].  Quantity matters far more with objects that have quality or decorations than boulders, as they take up more memory.  Temperature checks, wear increments, and other issues lag the game, although it takes far larger item quantities (10,000+) to be seriously notable.   
 
** That said, [http://www.bay12forums.com/smf/index.php?topic=104643.msg3094753#msg3094753 total quantity of items does matter].  Quantity matters far more with objects that have quality or decorations than boulders, as they take up more memory.  Temperature checks, wear increments, and other issues lag the game, although it takes far larger item quantities (10,000+) to be seriously notable.   

Revision as of 11:52, 4 July 2023

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-game, go to settings - Game and turn Show frames-per-second to Yes. Then your FPS will be displayed on the bottom 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 that's active keeps your game running fast. The vast majority of processing time in Dwarf Fortress is taken up by units taking their turns, over 60% in larger forts, of which less than 10% is actually pathfinding related, so the best way to prevent FPS loss is to reduce the amount of units spawned in general. The lists below 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.txt and D_init.txt files that don't actually change how the game plays out.

World Generation

  • Larger worlds require more background processing to update. The larger the civilizations, the more events occur in the world and the more complex they are. Generating too-large civilized populations can result in a permanent, unavoidable FPS drop. However, with how rich the game is with content, even a small world will be fairly interesting, while leading to a much higher framerate, though you may want to adjust some of the advanced world generation settings.
  • Longer histories require more memory and storage space for historical figures and events.
  • Reducing the number of civilizations, sites, beasts, and setting world population cap can limit the resources spent updating the rest of the world.
  • Caverns can be an FPS hog due to the large amount of creatures that spawn there if fiddled with. Sometimes even trading caravans will try to path out of your fort underground.
    • Adjusting the cavern layer number in advanced world generation parameters can reduce the number of cavern layers (default 3). However, this will restrict access to subterranean plants and creatures, and reduce the number of spawned forgotten beasts.
    • Similarly, one could adjust Layer Openness and Layer Passage Density in advanced world generation to make the caverns have fewer tiles to path through. In general, the pathfinding algorithm heuristically treats distances as a chess king moving in 3D ("Chebyshev distance"), which means that it can tend to go to the right X/Y then start floodfilling dumbly through the entire Z from there until it can find a way up, at which point the whole process repeats, so having fewer cavern tiles is better and open areas are to be avoided.[1]
    • Generating a world using a "REGION" template (instead of an "ISLAND" template which is used by "Create New World!") can significantly reduce the height of caverns and also place them closer together, resulting in fewer Z-levels. This generally also requires embarking in an area that isn't very close to an ocean or a mountain peak.
  • Snow and ice melting can cause lag spikes.[Verify] You can generate a world without poles with a somewhat heightened temperature, or just embark somewhere which doesn't freeze over.

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 4×4 squares to 3×3 or even 2×2 will have an enormous impact on FPS.
    • Keep in mind that a 2×2 embark is only 25% of the size of a 4×4 embark. However, in 3D it is still a large enough area for many fortresses in normal play.
  • Line-of-sight calculations, even after optimizations in v50.05, are the slowest part of the game by a wide margin. This is O(n^2) by nature, so the only way to truly reduce it is to reduce the amount of units. That said, there are still ways you can reduce the issues.
    • Keep your dwarves spread far apart--units who are more than 26 units away from a given unit in any direction are not considered for line-of-sight calculations.
    • Avoid having only one meeting area that has hundreds of dwarves in it.
    • Try to break line-of-sight in various places to keep your dwarves from asking "friend or foe?" too often.
  • Fewer items inside a fort means fewer items checked for temperature, which is the only major performance issue items cause.
    • 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.
    • Use a Dwarven atom smasher to remove items, or donate them to passing caravans to be taken away.
    • Quantum stockpiles only help with game speed when you're looking at your stockpiles all the time.