RE-UE4SS icon indicating copy to clipboard operation
RE-UE4SS copied to clipboard

Performance issues

Open TeKett opened this issue 1 year ago • 27 comments

What if this absolutely destroys the performance of the game? The palworld community uses this for its modding, i have asked over on their reddit a couple days ago but got no response. I lose half my frames, get stutters, the game gets stuck for a dozen of seconds when it has to do any type of loading, like when starting, loading world (which sometimes crashes the game), and going back to the titel, and if i idle on titel. This happens with or without mods. Makes the game completely unplayable unless i want to be playing a slideshow. I seem to be the only one with this problem as far as i know.

TeKett avatar Jan 28 '24 14:01 TeKett

The only performance problems that I'm aware of from a standard installation of UE4SS are related to the GUI. You could try turn the GUI off in UE4SS-settings.ini.

UE4SS avatar Jan 28 '24 14:01 UE4SS

The only performance problems that I'm aware of from a standard installation of UE4SS are related to the GUI. You could try turn the GUI off in UE4SS-settings.ini.

Already did, which did not make a visible difference. I also tried to change the scan attempts, in case it was that, but no difference either.

TeKett avatar Jan 28 '24 14:01 TeKett

I'm unable to do any testing because I don't have access to the game.

@narknon Are you aware of any performance problems not related to the GUI when there are no mods enabled ? Perhaps you can help with profiling, and if you don't have access to the game, maybe you could provide steps that @TeKett can follow to do the profiling themselves.

UE4SS avatar Jan 28 '24 14:01 UE4SS

What is your PC build? If you have bad single core performance you may have a bad time.

narknon avatar Jan 28 '24 16:01 narknon

You can try turning off hooks in the [Hooks] section in UE4SS-settings.ini and see if that helps. We do some processing in those hooks so it's worth a try. You can also try set UseUObjectArrayCache to 0 in the [General] section, that will stop UE4SS from being notified whenever game objects are created or deleted. Note that you will get reduced functionality, please try this without any mods just to see if the performance gets better.

UE4SS avatar Jan 28 '24 16:01 UE4SS

Hi, I just tried both your suggestions and wanted to feed back

You can try turning off hooks in the [Hooks] section in UE4SS-settings.ini and see if that helps. We do some processing in those hooks so it's worth a try.

This did not fix the problem

You can also try set UseUObjectArrayCache to 0 in the [General] section, that will stop UE4SS from being notified whenever game objects are created or deleted. Note that you will get reduced functionality, please try this without any mods just to see if the performance gets better.

This DID work and completely removed the stuttering and dropped frames

EDIT: I have since tried this plus the below mod and the stuttering has not returned

https://www.nexusmods.com/palworld/mods/1?tab=files

Tom1817 avatar Jan 28 '24 18:01 Tom1817

What is your PC build? If you have bad single core performance you may have a bad time.

i9 9900k RTX 4070 Ti 64 GB 3600 MHz ram M2 SSD Samsung 970 EVO Plus, 2 TB

You can try turning off hooks in the [Hooks] section in UE4SS-settings.ini and see if that helps. We do some processing in those hooks so it's worth a try. You can also try set UseUObjectArrayCache to 0 in the [General] section, that will stop UE4SS from being notified whenever game objects are created or deleted. Note that you will get reduced functionality, please try this without any mods just to see if the performance gets better.

I will try it when i get time and see if it will help. What would reduced functionality entail? Would it break anything important when it comes to modding, since thats what im going to use it for?

TeKett avatar Jan 28 '24 20:01 TeKett

To maintainers: Please leave this issue open until the performance problem with UseUObjectArrayCache has been been investigated.

UE4SS avatar Jan 28 '24 20:01 UE4SS

This is known and why we want to move to fuobjecthashtables.

narknon avatar Jan 28 '24 21:01 narknon

What is your PC build? If you have bad single core performance you may have a bad time.

i9 9900k RTX 4070 Ti 64 GB 3600 MHz ram M2 SSD Samsung 970 EVO Plus, 2 TB

You can try turning off hooks in the [Hooks] section in UE4SS-settings.ini and see if that helps. We do some processing in those hooks so it's worth a try. You can also try set UseUObjectArrayCache to 0 in the [General] section, that will stop UE4SS from being notified whenever game objects are created or deleted. Note that you will get reduced functionality, please try this without any mods just to see if the performance gets better.

I will try it when i get time and see if it will help. What would reduced functionality entail? Would it break anything important when it comes to modding, since thats what im going to use it for?

TLDR: Turning off bUseUObjectArrayCache won't break mods, but it's very likely that some of the hooks will break some mods if they are turned off.

With bUseUObjectArrayCache set to 0, our custom GUObjectArray cache won't be enabled, which means every time a mod tries to fetch an object with StaticFindObject or FindFirstOf or a few other methods, they will have to iterate the entirety of the array that contains every single object in the game. The search bar in the live view tab in the GUI will also be disabled.

This is what each hook does, and will be unavailable when set to 0.

HookProcessInternal: RegisterCustomEvent (Lua), RegisterHook (Lua & C++) for non-native UFunctions.

HookProcessLocalScriptFunction: Same as HookProcessInternal. Both exist for compatibility reasons between different engine versions.

HookInitGameState: RegisterInitGameStatePreHook/RegisterInitGameStatePostHook (Lua & C++), BPModLoaderMod due to use of RegisterInitGameStatePostHook.

HookCallFunctionByNameWithArguments: RegisterCallFunctionByNameWithArgumentsPreHook/RegisterCallFunctionByNameWithArgumentsPostHook (Lua & C++).

HookBeginPlay: RegisterBeginPlayPreHook/RegisterBeginPlayPostHook, BPModLoaderMod due to use of RegisterBeginPlayPostHook.

HookLocalPlayerExec: RegisterULocalPlayerExecPreHook/RegisterULocalPlayerExecPostHook (Lua & C++)

UE4SS avatar Jan 28 '24 21:01 UE4SS

This is known and why we want to move to fuobjecthashtables.

I'm not sure what's so slow about our current cache system. I think some profiling is needed here to figure out what's going on. We aren't really doing that much stuff related to the cache.

The cache uses HookedStaticConstructObjectPost to cache actor instances and HookedUStructLink for classes and actor classes, and it does so by putting the objects into a std::vector which should be fast.

Maybe it's the invalidation of the cache that's slow ? To invalidate a cached object, we rely on UEs FUObjectDeleteListener to tell us when an object is removed from GUObjectArray, and then we iterate the vector until we find a matching object (by pointer) and delete it if we find it and otherwise we just iterate to the end. We also look for and delete the object from a different global cache implemented as std::unordered_map but we're using an optimization to avoid needing to look the object up by name (we use pointer instead) every time an invalidation check is made so I wouldn't think this would be particularly slow either.

UE4SS avatar Jan 28 '24 21:01 UE4SS

Frankly, if bUseUObjectArrayCache = 1 is so slow, we should set it to 0 by default in the non-dev releases.

UE4SS avatar Jan 28 '24 22:01 UE4SS

You can try turning off hooks in the [Hooks] section in UE4SS-settings.ini and see if that helps. We do some processing in those hooks so it's worth a try. You can also try set UseUObjectArrayCache to 0 in the [General] section, that will stop UE4SS from being notified whenever game objects are created or deleted. Note that you will get reduced functionality, please try this without any mods just to see if the performance gets better.

I tried to set UseUObjectArrayCache to 0/false, but it either did nothing or maybe improved loading very slightly. Tried both on and off a few times.

Turning off the hooks helped with ingame FPS/performance, but also disabled the mods, and loading is still "freezing". Which one of them is responsible for making mods work?

TeKett avatar Jan 29 '24 18:01 TeKett

You can try turning off hooks in the [Hooks] section in UE4SS-settings.ini and see if that helps. We do some processing in those hooks so it's worth a try. You can also try set UseUObjectArrayCache to 0 in the [General] section, that will stop UE4SS from being notified whenever game objects are created or deleted. Note that you will get reduced functionality, please try this without any mods just to see if the performance gets better.

I tried to set UseUObjectArrayCache to 0/false, but it either did nothing or maybe improved loading very slightly. Tried both on and off a few times.

Turning off the hooks helped with ingame FPS/performance, but also disabled the mods, and loading is still "freezing". Which one of them is responsible for making mods work?

You can read about what each hook does here: https://github.com/UE4SS-RE/RE-UE4SS/issues/315#issuecomment-1913727041

UE4SS avatar Jan 29 '24 18:01 UE4SS

Well, shit, my mods stopped working completely. So i have no clue if the hooks are doing anything mod related. ~~I can say tho that HookProcessLocalScriptFunction = 1 is causing the bad performance.~~

In my act of fixing my broken mods i also fixed this. Going to put the files side by side and check what i messed up

TeKett avatar Jan 29 '24 18:01 TeKett

Well ok, this is strange...

I got UE4SS a few days ago. I remember now that it played fine, or i at least didn't notice any issues other then some slow loading. Played for a few hours for a day or two then my game started slowly to run bad, like i already said. Thought it was just the game, but turning off UE4SS made it disappear and run fine again. Did some periodic testing with same results. Including moving the .dll to different folder, to turn it off.

Fast forward to this thread.

So. I deleted all the UE4SS files, and re-uncompressed them from the same rar file. And then ran the game with no changes to the config file. And... No issues other then the very slow loading, and freezing when loading into the world and when going back to the titel. Turning off the GUI helps with the freezing. No performance issues. HookProcessLocalScriptFunction stopped giving me problems.

Moving the old .dll back again and no performance issues. Comparing the config files and they are identical. If the MaxScanAttempts are too low then it fails to load the mods, likely because it starts to scan before what its looking for exists. Had no impact on performance though.

Personally i can live with the slow loading. I will make a post if it breaks again and game starts to run bad. If neither me or someone else makes another post basically by the end of the week i guess you can close it, and i can open it again if i get issues.

It could just have been windows being windows, since what i basically did was to move the .dll to the trash bin and then move it back.

TeKett avatar Jan 29 '24 19:01 TeKett

i would not mod just yet becuase the game is so early on anything could change and the release for this project is quite old now, i would hold off like the 2.5.2 release says and wait until 2.6 of this project to come out i think the biggest thing you could post is any log files to either this project or t the palmon devs themselves

SDUBZ avatar Jan 30 '24 09:01 SDUBZ

I'd like to mention that setting these two

bUseUObjectArrayCache = false
GuiConsoleEnabled = 0

helped me with the performance. At least I don't see any noticeable problems, aside from the game crashing every few hours like it usually does with or without UE4SS.

lainverse avatar Feb 01 '24 16:02 lainverse

Original issue re-appears after a few days, no clue as to why. If i replace the .dll it gets fixed again, so i can likely reproduce the issue.

Edit: sure enough, it keeps happening, and getting fixed when i replace the .dll, so someting is breaking it.

TeKett avatar Feb 03 '24 08:02 TeKett

I saw some people use an updated fork, whould that be any better?

TeKett avatar Feb 11 '24 07:02 TeKett

I saw some people use an updated fork, whould that be any better?

Not sure what you mean by "updated fork". We can't vouch for any version of UE4SS not found on this specific github. If you want to try some version of UE4SS not found on this github, obviously feel free to do that but we can't help you if you run into any problems.

UE4SS avatar Feb 11 '24 08:02 UE4SS

UE4SS 3.0 has been released since you created this issue, so you should try that version and see if it helps.

UE4SS avatar Feb 11 '24 08:02 UE4SS

Interesting, did not notice, will go and do that

TeKett avatar Feb 11 '24 09:02 TeKett

Palworld. Same problems with UE4SS 3.0.0 and 3.0.1. "bUseUObjectArrayCache = false" helps. At the same time, problems with freezes and crashes are completely eliminated and memory leaks are reduced.

intorr avatar Mar 02 '24 13:03 intorr

today i tried launching and it keeps crashing on alunch but cant see what is doing it UEMinidump.dmp can anyone help ?

SDUBZ avatar Mar 13 '24 11:03 SDUBZ

today i tried launching and it keeps crashing on alunch but cant see what is doing it UEMinidump.dmp can anyone help ?

I'm not a dev of UE4SS, but I think I see an issue. Have you upgraded to UE4SS 3.0.1, but haven't removed XIUNPUT1_3.dll from the game folder? I see both dwmapi.dll and xinput1_3.dll there. image In general, I'd recommend to use Vortex to install UE4SS and Nexus mods in Palworld. It does the job quite well.

If removing it won't fix your issue try to disable all your mods and enable them one-by-one or in batches if you have too many. Might be one of the recently installed/updated lua or blueprint mods.

lainverse avatar Mar 13 '24 17:03 lainverse

today i tried launching and it keeps crashing on alunch but cant see what is doing it UEMinidump.dmp can anyone help ?

I'm not a dev of UE4SS, but I think I see an issue. Have you upgraded to UE4SS 3.0.1, but haven't removed XIUNPUT1_3.dll from the game folder? I see both dwmapi.dll and xinput1_3.dll there. image In general, I'd recommend to use Vortex to install UE4SS and Nexus mods in Palworld. It does the job quite well.

If removing it won't fix your issue try to disable all your mods and enable them one-by-one or in batches if you have too many. Might be one of the recently installed/updated lua or blueprint mods.

i worked it out it was vertex mod manager readding the older files i removed before and thank you for your advice it was indeed those files <3

SDUBZ avatar Mar 14 '24 01:03 SDUBZ