ID Project Category View Status Date Submitted Last Update

0005971 Dwarf Fortress Dwarf Mode -- Jobs, Eating/Drinking public 2012-05-30 03:59 2014-07-23 12:43

Reporter ag

Assigned To Toady One

Priority low Severity minor Reproducibility always

Status resolved Resolution fixed

Platform OS OS Version

Product Version 0.34.10

Target Version Fixed in Version 0.40.05

Summary 0005971: Fat dwarves eating causes lag.

Description Wasted CPU can be expected to be on the order of 5-10%.



The lag is caused by the interaction of two factors:



1) When the unit's fat amount crosses a 2500 boundary, its clothing insulation is recomputed.

2) Fat is capped at 1000000, which is divisible by 2500.



The result is that for every unit at 1000000 fat with digestion counter active, it recomputes insulation every frame, because of jitter caused by interaction between +5 from digestion (hits the boundary) and -random from natural consumption (doesn't). This can be very easily worked around by capping at 999999 instead of 1000000.

Steps To Reproduce Set units to 1000000 fat and activate their digestion counter (the one incremented when eating/drinking non-water).

Additional Information Profiling graph with the problem active (see bottom left):

file:///home/sasha/Games/DF/profiling/log.ab2a.svg [^]

Profiling graph with digestion hacked to use 999999 instead of 1000000 as cap:

file:///home/sasha/Games/DF/profiling/log.ab2b.svg [^]



Also note in those graphs that checking caste flags approaches 8% CPU usage; it is very hard for me to estimate where most of those calls come, but it seems that checks for OPPOSED_TO_LIFE, CRAZED, and other CE_ADD_TAG affected ones amount to at least 50% of that. The simplest way to fix that is probably to cache those in another bitfield in the unit, so that active tag set could be computed simply as (base | added) & ~removed.

Tags No tags attached.