vgstation-coders / vgstation13

Butts
GNU General Public License v3.0
264 stars 541 forks source link

Meter Processing Needs Optimization #16315

Closed Shadowmech88 closed 6 years ago

Shadowmech88 commented 6 years ago

https://github.com/vgstation-coders/vgstation13/blob/a487be9ccc25bc2460b0069cc5db7906bd814b53/code/game/machinery/atmoalter/meter.dm#L38 Profiler output, sorted by self CPU: https://pastebin.com/Untkd8ik Profiler output, sorted by total CPU: https://pastebin.com/hJ7g1ngF

Apparently, this proc became very expensive because originally meters would only post_signal() if they were assigned a frequency, but then they were given a default frequency, meaning all meters now post_signal() on every tick.

A possible solution would be to either remove the default frequency they were given, or give them different criteria for calling post_signal() such as a broadcast toggle.

Shadowmech88 commented 6 years ago

Clusterfack says the high self CPU of post_signal() is due to /obj/machinery/meter/process() calling it every two seconds.

Exxion commented 6 years ago

It's not really the most expensive proc. It's the single proc that used the most CPU during the sample time, but the most expensive proc would be the one with the greatest total CPU. Self CPU is good to sort by because it tells you where the problems are, but where they matter is total CPU Self CPU is important because it's part of total CPU

That said, it's still pretty bad

Shadowmech88 commented 6 years ago

OP updated with new information.