Nebula
Nebula copied to clipboard
Optimize initialization and maploading
Description of changes
Performs a lot of optimizations across the codebase, some more experimental than others. I tested and got some pretty impressive results downstream on Spacefarers (loading in a new ship after roundstart took about 4 seconds instead of 16) and it seems like a lot of trouble spots in initialization are faster too.
The commit messages are descriptive, I would suggest referencing those for a description of what's included in this PR. Of particular note are these changes:
- /turf/unsimulated no longer goes through Initialize
- /obj/effect/floor_decal no longer goes through Initialize or Destroy
- update_alpha_mask now sleeps until, at minimum, the end of the tick (instead of only sleeping if the server was overloaded)
- A bunch of event registrations are now explicitly cleaned up in Destroy(), to avoid costly event cleanup code.
- Unregistering from the Moved event also unregisters from its parent. ~~(I'm unsure about this one but I couldn't see any other way to fix a bunch of hanging
recursive_move
event registrations.)~~ Seems to work like a charm. - A few things were changed to respect level data bounds, which is helpful to optimize smaller away sites in large worlds.
- SSambience avoids duplicate queueing and avoids costly removal attempts when we know the turf is not in the queue.
-
initial_gas = list(/decl/material/gas/oxygen = MOLES_O2STANDARD, /decl/material/gas/nitrogen = MOLES_N2STANDARD)
now has a special hot-path:initial_gas = GAS_STANDARD_AIRMIX
. This avoids creating a list per turf (including a unsimulated fillter turfs!), which saves memory and init time. - Turf height appearance icons are now cached.
- Unsimulated atoms skip visualnet updates, which makes ChangeTurf() and Destroy() even faster for them.
- Extra argument handling in
qdel()
afterforce
was removed. Nothing used this and it was a waste of processor time.
Why and what will this PR improve
Lots and lots of optimizations.
Authorship
One particular commit, Port InitAtom optimizations from tgstation
, is adapted from some of the changes made by Mothblocks on tgstation in this commit. The rest was all done by me, mostly for the downstream Spacefarers.