tgstation / dev-cycles-initiative

Hub for tracking issues in the Dev Cycles Initiative
1 stars 0 forks source link

`dcs/GetIdFromArguments` is too slow #5

Open Mothblocks opened 1 year ago

Mothblocks commented 1 year ago

This is called every time a bespoke element is added.

Estimated Cost

As of December 2, 2022, /datum/controller/subsystem/processing/dcs/proc/GetIdFromArguments is 793ms.

Solutions

GetIdFromArguments exists to ensure that elements with the same parameters always resolve to the same instance. Prior efforts to try to guarantee this statically have not been successful with edge cases.

It is also possible to cache this ID where it is known not to change.

It is not obvious (to me, anyway) how this could be done without introducing a footgun, breaking our 99th percentile goal.

Mothblocks commented 1 year ago

/obj/item/proc/add_weapon_description is 319ms. /datum/element/atmos_sensitive/Attach is 191ms.

Nearly all of this is GetIdFromArguments.