NieRAutomata-LodMod
NieRAutomata-LodMod copied to clipboard
Worse performance/latency in 2021 compared to 2017
It's been claimed that the 2021 build performs worse than the older, denuvo'ed 2017 build, with 2021 apparently having worse performance & latencies.
I haven't actually checked the performance myself, but do trust the ones claiming this, porting LodMod across each version also revealed a likely cause: 2021 seems to have much less build optimizations applied compared to 2017.
No idea if this was a deliberate change, or maybe something that happened with different compiler/build-environments being used, I just know some pretty beneficial build optimizations are no longer being used in the 2021 build for some reason.
As an example, there's a function I name as cMapControllerBase::Init (2017 addr: 0x5A5220, 2021/Win10 addr: 0x7D51B0)
In the 2021 build, this takes a 2nd parameter which is a constant of 7, this never changes and is hardcoded in the EXE (and is also part of what LodMod's HQMapSlots feature updates)
In 2021 you can see that the parameter given to this function gets used for calculations of a bunch of sizes/offset, is pushed/popped from stack, passed to subroutines called inside it... in other words, a lot of code is ran which calculates things based on this (never changing) parameter.
Meanwhile in the 2017 build, optimizations allowed the compiler to realize that the constant 7 never changes, and there's no need to calculate any things at runtime: all those sizes/offsets can be mostly calculated during build & hardcoded instead, the function doesn't even seem to take in a parameter to define it anymore, instead that (and the subroutines it calls) all have the constant 7 (and anything calculated based on that 7) hardcoded inside them.
That's just an example from a part of the code I've been working on, things like that can be seen everywhere when comparing 2021 vs 2017 (along with even worse things like dead-code being ran, or calls everywhere to non-inlined 1-line functions...)
From a modding pont-of-view the unoptimized 2021 is a lot nicer to work with though -- a lot of the LodMod changes would have been much harder to figure out in the 2017 version -- I don't really think this modding benefit outweighs the performance drop from it though.
Until another 4 years pass and SQEX maybe (probably not) decides on another update, I'd guess our only option is to somehow salvage the code we already have.
Maybe it's possible to profile the game and find hotspots, and then "transplant" 2017's code over them, I've done this with code from 2017-debug into 2021 already, depending on the code it isn't too difficult, as usual the harder part is finding the code that needs it... I've never really done profiling of black-box games like this before though, not even sure how possible it is.
Any other ideas would be appreciated, if all else fails we can just downgrade to the 2017 build I guess, but who knows how long Denuvo activation will last for it...
(also before it's brought up, Denuvo doesn't seem to be a cause of the optimization differences here - 2017 debug was also Denuvo'd, and the level of optimization there is pretty much just as bad as the current 2021 build, actually worse in some cases probably due to using debug build config, so IMO it's unlikely that Denuvo somehow optimized the 2017 build)