zymex22 / Project-RimFactory-Revived

Project RimFactory Revived
MIT License
45 stars 34 forks source link

Drones Performance - Analyze #217

Open zymex22 opened 3 years ago

zymex22 commented 3 years ago

Describe the bug

Over time Cultivators seem to use much performance, seems to be due to Building_DronestationSpecialGraphic which are running at crazy 200ms.

its used with <DrawDormantDrones> to show dormat drones on a station

To me this should either be fixed or removed, i dont think show drones are worth extra lag. i have aldready turned it off on normal drone stations where it does not fit texture.

TODO

Sn1p3rr3c0n commented 3 years ago

Update This issue is only seen with the "Drones" Extension

After spending too much time on this i can finally conclude that this is not an issue with DrawDormantDrones.

<ThingDef ParentName="PRF_DroneStationBase">
    <defName>CaretakerDroneStation</defName>
    <label>caretaker drone station</label>
    <description>A station that holds up to 20 drones, capable of hauling and cleaning, flicking and fighting fires. Consumes considerable power. Typically your colony only needs 1 of these.</description>
    <thingClass>ProjectRimFactory.Drones.Building_DroneStationSpecialGraphics</thingClass>
    <graphicData>
      <texPath>Drones/DroneStationCaretaker</texPath>
      <graphicClass>Graphic_Single</graphicClass>
      <shaderType>CutoutComplex</shaderType>
      <drawSize>(2,2)</drawSize>
    </graphicData>
    <size>(2,2)</size>
    <costList>
      <Steel>100</Steel>
      <ComponentSpacer>5</ComponentSpacer>
      <ComponentIndustrial>5</ComponentIndustrial>
      <PRFWeakAIChip>12</PRFWeakAIChip>
    </costList>
    <modExtensions>
      <li Class="ProjectRimFactory.Drones.DefModExtension_DroneStation">
        <displayDormantDrones>true</displayDormantDrones>
        <workTypes>
          <li>Firefighter</li>
          <li>BasicWorker</li>
          <li>Hauling</li>
          <li>Cleaning</li>
        </workTypes>
      </li>
    </modExtensions>
    <comps>
      <li Class="CompProperties_Power">
        <compClass>CompPowerTrader</compClass>
        <shortCircuitInRain>false</shortCircuitInRain>
        <basePowerConsumption>1000</basePowerConsumption>
      </li>
    </comps>
    <researchPrerequisites>
      <li>PRFCaretakerDrones</li>
    </researchPrerequisites>
  </ThingDef>

As seen in the xml for some reason <thingClass>ProjectRimFactory.Drones.Building_DroneStationSpecialGraphics</thingClass> was selected as the Class for the Station

Sn1p3rr3c0n commented 3 years ago

@zymex22 why did you use <thingClass>ProjectRimFactory.Drones.Building_DroneStationSpecialGraphics</thingClass> for them?

it seems as if public ThinkResult TryIssueJobPackageDrone(Pawn pawn, bool emergency) takes significantly more time for the Caretaker (maybe related to haul?)

Sn1p3rr3c0n commented 3 years ago

This post shall be updated to provide an collected Overview of all Scenarios where Reduced performance can be observed

Testing on 18.11.20 (Based on master)

Vanilla Modlist

Harmony, Core, Royalty, HugsLib, DubsPerformenceAnalyzer, PRF

Scenario - 1 Drones have the "Haul Job" enabled with a a lot of haulabel things that cant be moved as the target is out of range.

In this Scenario a ~3ms Ticktime Increases to 10ms image Image shows the 3ms Time. if the range is increased while the haul job is active the time will increase to 10ms

Other Observations:


"Bigger Mod list" (provided by itengineer)

full list by itengineer ```XML
  • brrainz.harmony
  • ludeon.rimworld
  • ludeon.rimworld.royalty
  • unlimitedhugs.hugslib
  • dubwise.dubsperformanceanalyzer
  • vanillaexpanded.achievements
  • spdskatr.projectrimfactory
  • brrainz.achtung
  • fluffy.modmanager
  • unlimitedhugs.allowtool
  • razor2.3.anotherrimworldmod.autocutblight
  • gguake.ui.simplesearchbar
  • arandomkiwi.rimsaves
  • mlie.wikirim
  • valcrafto.rimsearch
  • savestoragesettings.kv.rw
  • fluffy.worktab
  • tikubonn.dontblockdoor
  • notfood.frameratecontrol
  • mehni.numberspatched
  • sarg.smartspeed
  • smashphil.neceros.srtsexpanded
  • dhultgren.smarterconstruction
  • giantspacehamster.moody
  • unlimitedhugs.mapreroll
  • krafs.levelup
  • jkluch.haultostack
  • mlie.apparelorganizer
  • madeline.modmismatchformatter
  • fluffy.colonymanager
  • dubwise.dubsmintminimap
  • com.bymarcin.architecticons
  • dubwise.dubsmintmenus
  • taveron.increasedstack
  • fluffy.blueprints
  • notfood.researchpal
  • dubwise.rimatomics
  • dubwise.rimefeller
  • arandomkiwi.rimthemes
  • proxyer.optionalicons4ai
  • fed1splay.pawntargetfix
  • linkolas.stabilize
  • void.charactereditor
  • leafzxg.masterofcrafting
  • syrchalis.setupcamp
  • mlie.xndmemorableauroras
  • jaxe.rimhud
  • roolo.giddyupcore
  • mlie.rimquest
  • yrtwof.rimpedia
  • kikohi.jewelry
  • mlie.pickupandhaul
  • acruid.repairbench
  • daniledman.fastregen
  • ratys.rtfuse
  • murmur.walllight
  • orion.therapy
  • targhetti.showdrafteesweapon
  • leafzxg.masterofcooking
  • timmyliang.tradehelper
  • vfme.caravanpacks
  • rikiki.miningco.spaceship
  • neceros.reinforcedwalls
  • meltup.beautifuloutdoors
  • roolo.giddyuprideandroll
  • mlie.centralizedclimatecontrol
  • roolo.giddyupcaravan
  • roolo.giddyupbattlemounts
  • roolo.runandgun
  • wit.expandedroofing
  • user19990313.runtimegc
  • roolo.searchanddestroy
  • com.yayo.betterjumppack
  • syrchalis.doormats
  • tammybee.whereismyweapon
  • cabbage.rimcities
  • petetimessix.simplesidearms
  • brrainz.cameraplus
  • lwm.deepstorage
  • ```

    Current Progress in reducing the List

    <li>brrainz.harmony</li>
        <li>ludeon.rimworld</li>
        <li>ludeon.rimworld.royalty</li>
        <li>unlimitedhugs.hugslib</li>
        <li>dubwise.dubsperformanceanalyzer</li>
        <li>vanillaexpanded.achievements</li>
        <li>spdskatr.projectrimfactory</li>
        <li>brrainz.achtung</li>
        <li>fluffy.modmanager</li>
        <li>unlimitedhugs.allowtool</li>
        <li>razor2.3.anotherrimworldmod.autocutblight</li>
        <li>gguake.ui.simplesearchbar</li>
        <li>arandomkiwi.rimsaves</li>
        <li>mlie.wikirim</li>
        <li>valcrafto.rimsearch</li>
        <li>savestoragesettings.kv.rw</li>
        <li>fluffy.worktab</li>
        <li>tikubonn.dontblockdoor</li>
        <li>notfood.frameratecontrol</li>
        <li>mehni.numberspatched</li>
        <li>sarg.smartspeed</li>
        <li>smashphil.neceros.srtsexpanded</li>
        <li>dhultgren.smarterconstruction</li>
        <li>unlimitedhugs.mapreroll</li>
        <li>krafs.levelup</li>
        <li>mlie.apparelorganizer</li>
        <li>madeline.modmismatchformatter</li>
        <li>fluffy.colonymanager</li>
        <li>dubwise.dubsmintminimap</li>
        <li>com.bymarcin.architecticons</li>
        <li>dubwise.dubsmintmenus</li>
        <li>fluffy.blueprints</li>
        <li>notfood.researchpal</li>
        <li>dubwise.rimatomics</li>
        <li>dubwise.rimefeller</li>
        <li>arandomkiwi.rimthemes</li>
        <li>proxyer.optionalicons4ai</li>
        <li>fed1splay.pawntargetfix</li>
        <li>linkolas.stabilize</li>
        <li>void.charactereditor</li>
        <li>leafzxg.masterofcrafting</li>
        <li>syrchalis.setupcamp</li>
        <li>mlie.xndmemorableauroras</li>
        <li>jaxe.rimhud</li>
        <li>roolo.giddyupcore</li>
        <li>yrtwof.rimpedia</li>
        <li>kikohi.jewelry</li>
        <li>acruid.repairbench</li>
        <li>daniledman.fastregen</li>
        <li>ratys.rtfuse</li>
        <li>murmur.walllight</li>
        <li>targhetti.showdrafteesweapon</li>
        <li>leafzxg.masterofcooking</li>
        <li>timmyliang.tradehelper</li>
        <li>vfme.caravanpacks</li>
        <li>rikiki.miningco.spaceship</li>
        <li>neceros.reinforcedwalls</li>
        <li>meltup.beautifuloutdoors</li>
        <li>roolo.giddyuprideandroll</li>
        <li>mlie.centralizedclimatecontrol</li>
        <li>roolo.giddyupcaravan</li>
        <li>roolo.giddyupbattlemounts</li>
        <li>roolo.runandgun</li>
        <li>wit.expandedroofing</li>
        <li>user19990313.runtimegc</li>
        <li>roolo.searchanddestroy</li>
        <li>com.yayo.betterjumppack</li>
        <li>syrchalis.doormats</li>
        <li>tammybee.whereismyweapon</li>
        <li>cabbage.rimcities</li>
        <li>petetimessix.simplesidearms</li>
        <li>brrainz.cameraplus</li>
        <li>lwm.deepstorage</li>

    I can confirm a substantial loss in tps by the drone station

    TODO:

    Sn1p3rr3c0n commented 3 years ago

    Possible future performance improvements

    For Building_DroneStation (In Case of no Job)

    The only call where its plausible that noticeable Improvements can be made is TryGiveJob. There 2 Options remain:

    a third option wold be to tune additionJobSearchTickDelay. Current feedback shows that the reduction of responsiveness caused by it is not observed by the users. -> It is likely that we could Reduce the responsiveness even more and therefor also reduce the tick time.

    For Pawn_Drone (In Case of some Job(s))

    The lag seems to be caused by base.Tick(); more specifically JobTrackerTick() but i have no clue how to improve it

    Sn1p3rr3c0n commented 3 years ago

    Check if the Calls to SetPriority can be reduced. as WorkTab has a patch for that function that reportedly take ~20ms (spike) late game (modded).

    This behavior is unexpected as the code in said patch is simple & dos not seem like the execution time should or Could increase

    Madman666: Yeh, so in short: 1) Create a new map 2) Dev mode spawn some power and a drone Cultivator mk3 3) Dev spawn some pawns 4) Make a big grow zone for drones to work on 5) Watch WorkTab.Pawn_WorkSettings_SetPriority:Prefix get frequent big spikes in frametime. Seems to scale with both pawn amounts and drone amounts. In my case it was spiking in my modded testing save to about 20 ms, on newly created map with just PRF and WorkTab - to 5-6 ms per dronebase. https://cdn.discordapp.com/attachments/693933621349974040/797895773513318420/unknown.png

    combustor commented 3 years ago

    image yeah drones eat my performance up didn't realize it until it was too late