Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005971Dwarf FortressDwarf Mode -- Jobs, Eating/Drinkingpublic2012-05-30 03:592014-07-23 12:43
Assigned ToToady One 
PlatformOSOS Version
Product Version0.34.10 
Target VersionFixed in Version0.40.05 
Summary0005971: Fat dwarves eating causes lag.
DescriptionWasted 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 ReproduceSet units to 1000000 fat and activate their digestion counter (the one incremented when eating/drinking non-water).
Additional InformationProfiling 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.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
ag (reporter)
2012-05-30 04:03

Correct graph links: [^] [^]

- Issue History
Date Modified Username Field Change
2012-05-30 03:59 ag New Issue
2012-05-30 04:03 ag Note Added: 0022787
2014-07-23 12:43 Toady One Status new => resolved
2014-07-23 12:43 Toady One Fixed in Version => Next Version
2014-07-23 12:43 Toady One Resolution open => fixed
2014-07-23 12:43 Toady One Assigned To => Toady One

Copyright © 2000 - 2010 MantisBT Group
Powered by Mantis Bugtracker