tgstation / dev-cycles-initiative

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

Separate `preference/init_possible_values()` from icon generation #2

Closed Mothblocks closed 8 months ago

Mothblocks commented 1 year ago

Even with lazy asset loading, every preference still creates lots of icons in their init_possible_values() functions. init_possible_values(), of many preferences, returns both the asset name AND the icons.

Estimated Cost

/datum/asset/json/preferences/generate is 3.3s with CACHE_ASSETS on (not sure how much higher off). Of that 3.3s, 2.21s (67%) is hairstyle/compile_constant_data. 553ms is choiced/compile_constant_data generally, followed by 484ms of facial_hairstyle/compile_constant_data.

Solutions

init_possible_values() can be changed to only give text values, with icon generation being a separate proc. This would be accompanied by a unit test to make sure every value has an associated icon (if icons are applicable to the setting). This would, ideally, defer costs until the preferences menu is loaded when clicking setup character (since preference asset generation is lazy, even when uncached).

Mothblocks commented 1 year ago

Because the assets don't load until you click preferences menu, this represents a 3.3 second cost save there too (until you open prefs).

itsmeow commented 8 months ago

This can be closed. https://github.com/tgstation/tgstation/issues/77660