Testing effects of open space on FPS using dfhack.
The goal is to increase understand of long term FPS loss with the hope of discovering how to decrease or eliminate it.
Summary of Conclusions:
Pathfinding is a lot more significant than open space with regards to FPS. Clearing a large section of the map only has about a 12% effect on FPS in and of itself. Pathfinding through that space while unable to reach the destination had about 5 times more effect on FPS. I didn't count the number of flying clowns. Visible but non-open tiles do not seem to have a significant effect.
Also, we could probably get better results by timing how long it takes to finish the season rather than a subjective evaluation of the FPS meter, then timing the second season, as paths and such would be cached by then.
Further research questions:
* Redo the experiments measuring elapsed real-time per season rather than looking at the FPS meter.
* Is dfhack tiletypes and manual in-game digging equivalent in terms of FPS?
* If the clowns could reach the dwarfs, would that reduce the FPS penalty?
* Large amounts of accessible/inaccessible floor (as opposed to open air) would be interesting to look further into, as the results were strange. Ghostwoods's experiment was in this vein.
* How much would it affect FPS if the dwarfs were able to reach the empty space (or floor), then it was blocked off by various methods (wall, floor, bridge, door).
* (Tangental) Is clown release deterministic?
* (Tangental) Get someone to put up a series of saves for a fort suffering from long term FPS loss, starting from embark, so that a comparative analysis can be done. What year has the largest FPS loss? What changed? In years that have little FPS loss, what changed so we can rule it out?
Baseline parameters:
FPS cap set to 10k
All tests were started with a fresh copy of the fork, and terminated at the end of the first spring.
All setup was done before the first unpause after loading. No changes were made after that.
In most tests, FPS has an initial stable value and a second stable value after a few weeks game time. The final stable value is the one reported.
It isn't part of the experiment, but DF is running in a VM.
Test 0: Save with no changes
FPS seems stableish at 400.
Test 1: 129 z-levels of open air (with clown introduced measurement error)
Go to level -3, set hotkey F3
K, move curser to NW corner, then move SE 1 tile.
liquids
range
x: 92, y: 92, z: 131, depth: 0
<enter>
q
tiletypes
range
x: 92, y: 92,z: 131
paint mat stone
paint sh wall
paint hidden 0
<enter>
Move cursor 1 more tile SE, and up 1 zlevel
range
x: 90, y: 90,z: 129
paint mat air
paint sh empty
<enter>
(Oops, the circus came to town, water fills a few individual squares.)
FPS seems to be at a stable 200, sometimes dropping to 160-180, went all the way up to 250.
Test 2: 3 z-levels of open air (with clown introduced measurement error)
Go to level -3, set hotkey F3
K, move curser to NW corner, then move SE 1 tile.
liquids
range
x: 92, y: 92, z: 5, depth: 0
<enter>
q
tiletypes
range
x: 92, y: 92,z: 5
paint mat stone
paint sh wall
paint hidden 0
<enter>
Move cursor 1 more tile SE, and up 1 zlevel
range
x: 90, y: 90,z: 3
paint mat air
paint sh empty
<enter>
(Oops, the circus came to town, water fills a few individual squares.)
FPS eventually stabilised in the 300-320 range, with spikes to 360.
Conclusions for tests 1 & 2:
We can conclude that ~1M tiles of inaccessible empty space drops FPS by ~68%, or put differently, every 15k visible tiles drops FPS by ~1% (assuming it's linear).
Oops, I made a mistake. Flying clowns need to pathfind through all that space. That invalidates the results as pathfinding and open space have became conflated.
It should be noted that if no path to the destination is available A* will do a complete and exhaustive search of every tile accessible to the unit, which is a huge performance hit. This is pretty much worst case for A* pathfinding.
Let's try this again without clowns.
Test 3: 128 z-levels of visible open air.
Go to level 2, set hotkey F3
K, move curser to NW corner, then move SE 1 tile.
liquids
range
x: 92, y: 92, z: 130, depth: 0
<enter>
q
tiletypes
range
x: 92, y: 92,z: 130
paint mat stone
paint sh wall
paint hidden 0
paint special 0
<enter>
Move cursor 1 more tile SE, and up 1 zlevel
range
x: 90, y: 90,z: 128
paint mat air
paint sh empty
<enter>
FPS eventually stabilised in the 340-360 range, with spikes to 400.
Test 4: 3 levels of visible open air
Go to level 2, set hotkey F3
K, move curser to NW corner, then move SE 1 tile.
liquids
range
x: 92, y: 92, z: 5, depth: 0
<enter>
q
tiletypes
range
x: 92, y: 92,z: 5
paint mat stone
paint sh wall
paint hidden 0
paint special 0
<enter>
Move cursor 1 more tile SE, and up 1 zlevel
range
x: 90, y: 90,z: 3
paint mat air
paint sh empty
<enter>
FPS eventually stabilises at 400, spiking to 420 and dropping to 360.
Conclusion for Tests 3 & 4:
We can conclude that ~1M tiles of inaccessible empty space drops FPS by ~12%, or put differently, every 83k visible tiles drops FPS by ~1% (assuming it's linear, which it probably isn't).
Further, we can attempt to unconflate pathfinding from the first run through. It seems ~84.6% of the FPS drop in the first run through can be attributed to pathfinding. Therefore FPS reduced by pathfinding through 98k empty tles is about 58%. Put another way, every 98k visible tiles reduced FPS by 1% due to pathfinding. (same linear disclaimer as above.)
-- Additional experiments --
Test 5: 128 z-levels of visible stone wall.
Go to level 2, set hotkey F3
K, move curser to NW corner, then move SE 1 tile.
liquids
range
x: 92, y: 92, z: 130, depth: 0
<enter>
q
tiletypes
range
x: 92, y: 92,z: 5
paint mat stone
paint sh wall
paint hidden 0
paint special 0
<enter>
FPS eventually stabilises at 380-400.
Conclusion for test 5:
Visible, unopen space had no noticable effect on FPS.
Test 6: 128 z-levels of floor
Go to level 2, set hotkey F3
K, move curser to NW corner, then move SE 1 tile.
liquids
range
x: 92, y: 92, z: 130, depth: 0
<enter>
q
tiletypes
range
x: 92, y: 92,z: 130
paint mat stone
paint sh wall
paint hidden 0
paint special 0
<enter>
Move cursor 1 more tile SE, and up 1 zlevel
range
x: 90, y: 90,z: 128
paint sh floor
<enter>
FPS seems a lot more variable, fluctuating from at least several seconds of stability at many values between 140 and 400. If I had to pick a number, I would say 200, but I definitely did not get a good reading.
No conclusions drawn due to poor measurements
Test 7: 128 z levels of visible air with access via stairs
Go to level 2, set hotkey F3
K, move curser to NW corner, then move SE 1 tile.
liquids
range
x: 92, y: 92, z: 130, depth: 0
<enter>
q
tiletypes
range
x: 92, y: 92,z: 130
paint mat stone
paint sh wall
paint hidden 0
paint special 0
<enter>
Move cursor 1 more tile SE, and up 1 zlevel
range
x: 90, y: 90,z: 128
paint mat air
paint sh empty
<enter>
Move cursor to NW corner of level 131, and then move SE by 2
range
x: 1, y: 1,z: 20
paint mat stone
paint sh stair_updown
F3 and up a level, so the same stuff is on-screen as in other tests while we're checking FPS
FPS: 340-360 It seemed to take longer to reach the stable point than test 3, but that wasn't measured.