Skip to content

Speed up file loading on server join by splitting P_AddWadFile into stages

X.organic requested to merge X.organic/Kart-Public:split-netfil-loading into next

The setup functions in P_AddWadFile have been split into groups for this purpose - the ones that take a wadnum argument, like R_AddSkins, and the ones that always iterate over every WAD, like P_InitPicAnims. The latter group is only called once in this scenario. This should be netgame-compatible in every scenario, unless repeated loading of TEXTURES SOCs has a different effect from loading them once, which… really shouldn't be a thing.

This effectively turns the complexity of loading files on join close to linear, with about 20 P_PartialAddWadFile calls done per second, then P_MultiSetupWadFiles (spread out over 3 tics) taking a split second, resulting in 3x to 4x speed boost. Compare this to the current vanilla behavior where over time, P_AddWadFile slows down to only being doable 7 or fewer times per second. For some concrete numbers: around the time of writing, on my hardware, joining CGB Styles with all the addons downloaded took about 11 seconds to load addons, 3s for the other steps (MD5 check, connection etc., unaffected by this branch). With this patch, the addon load took 3.1 seconds. And that's for 112-ish addons. On Patafoin's server, at 83 addons, the addon load times were 7.2s and 2.3s respectively, and I expect to see a performance boost even higher than 4x in many 1.6 servers now that !291 (merged) (double WAD and skin slots) has been merged.

Additionally, a minor speedup is granted to loading clientside-safe ("unimportant") addons – music WADs, permitted HUD changes etc. – via addfile, as the setup stages that are never necessary for such addons are omitted.

Edited by X.organic

Merge request reports