Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply a large number of optimizations #4698

Merged
merged 19 commits into from
Jan 8, 2025

Conversation

out-of-phaze
Copy link
Member

Description of changes

  • Ports TG's ref()less GC queues, avoiding string tree rebalances and making it more accurate. To do this it uses refcount() to determine when something has no remaining references, rather than waiting for it to just fall out of the queue via softdel.
  • Avoid repeated implicit var/turf/T in world loops in recalculate_vessel_mass().
  • Removes the ID var from seed piles and makes it use an index instead, like vendors.
  • Avoids updating the storage UI if the storage object has been qdel'd. This avoids a ton of unnecessary appearance updates of items that are more than likely going to be deleted on the same tick. (Any former storage contents not deleted are going to end up hud_layerizeing or whatever when they move to another loc as part of not-being-deleted, so updating the UI was just totally redundant.)
  • Reuses the icon state cache for things that iterate icon_states().
  • Make the state machine list use hardrefs (since they're cleared on destroy anyway).
  • Makes the NanoUI open UIs list use hardrefs, for the same reason as the state machine list.

I should really spin up a test server to test some of the more fragile changes like the seed stuff, world/inventory icons, etc. As far as I saw when I spun up a server locally to benchmark and sat in the lobby to watch the GC queue, things pass GC just fine.

Also some non-optimization changes:

  • Fixes incorrect argument order to check_state_in_icon() in bookshelf code.
  • Fixes unnecessary usage of \the [foo.name] in strings.

Why and what will this PR improve

From my local benchmarking:
~20% save on get cached info
~8% on get instance of
~7.5% on reconsider single icon
~12% on recalculate_vessel_mass
~8.5% overall on /obj/item/Initialize
~23% overall on /atom/proc/Initialize
~27.5% save in /datum/proc/Destroy

Authorship

ref()less GC queues taken from TG master at the time of writing this PR. Original implementation on TG was here: tgstation/tgstation#72033 but it has been overhauled several times since.
Everything else is by me.

Changelog

No user-facing changes.

@out-of-phaze out-of-phaze added the ready for review This PR is ready for review and merge. label Jan 5, 2025
@out-of-phaze out-of-phaze force-pushed the optimize/ship-mass branch 4 times, most recently from fa16773 to 3014d48 Compare January 5, 2025 23:50
@MistakeNot4892 MistakeNot4892 merged commit c2daacc into NebulaSS13:dev Jan 8, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review This PR is ready for review and merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants