Closed SiverDX closed 10 months ago
Interesting. I am not able to replicate any performance differences on my end.
Are you experiencing this with other mods installed? If so, do you still experience it with just Raised?
Doesn't happen with only Raised
If you add ImmediatelyFast it slightly increases it? Could be margin of error or maybe the start of a snowball effect? Not really sure
I see now that website you have a lot of mods on it. Doing it for myself Raised with like 10-15 mods it still is so low performance it doesn't even register on the chart.
Do me a favor and turn extended mod support to false. If that does it I think I may have a clue.
Setting it to false results in a very low performance impact (like with no mods) (Is it intended that you need to restart the game for the change to take effect?)
Well I am wondering if it has anything to do with the RegisterGuiOverlaysEvent. Since in 1.19+ some mods use this to register their GUIs, like Tough As Nails, I modified it to add the identifier to the list of identifiers to check the overlay against.
Unfortunately, the namespace is assumed in Forge when the mod registers it, so the register method only has a String for the path... so like toughasnails:temperature_level
as an identifier is only temperature_level
. My only idea on how to then get these registered is to just get the list of all mods loaded by Forge and register each element's ID with every mod namespace.
Now, it only does this once when the game is loading early on, but I suppose if you have a lot of mods or mods that add a lot of elements with this event, then the list of things to check the HUD element against to see if it should move it would be pretty big. That may incur a performance loss.
https://github.com/yurisuika/Raised/actions/runs/6563111615
When this is done running, try using it. If that is the case, then you should have good performance with extended mod support on or off. Basically I just disabled that code.
The registering is tied to that option, so this is why it would only work with the restart, because it just adds them to memory.
Seems to be fine with that version (and config set to true)
As I thought, I am guessing there is some big list that the HUD elements are checked against each time. I'd imagine that is what is driving down the performance.
https://github.com/yurisuika/Raised/actions/runs/6563720836
This reenables that but also puts a logger on there, so it should spit out everything that is registered. You'll probably get some huge list (could potentially be thousands of lines long).
Yeah around 8000 entries, every (or a lot) mod gets an entry for every vanilla and modded overlay
https://gist.github.com/SiverDX/be5b932272fea9a9405012002dc79c9d
While the "other" identifier for an overlay in RegisterGuiOverlaysEvent isn't like the overlay in RenderGuiOverlayEvent (it is just saying where the registered HUD element should be placed in relation to the Z-Index or whatever for that other element), it is kinda the only way for me to say if a HUD element registered with this event should be moved. Not that it is necessarily the case, but it is a good thing to go off of.
oh well I solved it!
ModLoadingContext.get().getActiveNamespace();
is what I was looking for all along... since I am injecting this into Forge code, it will return whatever namespace the mod is that I am trying to add the HUD stuff for.
https://github.com/yurisuika/Raised/actions/runs/6564828901
This should hopefully be the remedy. You should find it only spits out a list of what is actually registered now.
Seems good
[18Oct2023 20:15:13.539] [Render thread/INFO] [raised/]: Registering mod element: leavemybarsalone:food_level_mounted above minecraft:food_level
[18Oct2023 20:15:13.539] [Render thread/INFO] [raised/]: Registering mod element: leavemybarsalone:experience_bar_mounted above minecraft:experience_bar
[18Oct2023 20:15:13.545] [Render thread/INFO] [raised/]: Registering mod element: sophisticatedstorage:storage_tool_info above minecraft:hotbar
[18Oct2023 20:15:13.545] [Render thread/INFO] [raised/]: Registering mod element: create:remaining_air above minecraft:air_level
[18Oct2023 20:15:13.546] [Render thread/INFO] [raised/]: Registering mod element: create:train_hud above minecraft:experience_bar
[18Oct2023 20:15:13.546] [Render thread/INFO] [raised/]: Registering mod element: create:value_settings above minecraft:hotbar
[18Oct2023 20:15:13.547] [Render thread/INFO] [raised/]: Registering mod element: create:track_placement above minecraft:hotbar
[18Oct2023 20:15:13.547] [Render thread/INFO] [raised/]: Registering mod element: create:goggle_info above minecraft:hotbar
[18Oct2023 20:15:13.549] [Render thread/INFO] [raised/]: Registering mod element: create:blueprint above minecraft:hotbar
[18Oct2023 20:15:13.550] [Render thread/INFO] [raised/]: Registering mod element: create:linked_controller above minecraft:hotbar
[18Oct2023 20:15:13.551] [Render thread/INFO] [raised/]: Registering mod element: create:schematic above minecraft:hotbar
[18Oct2023 20:15:13.551] [Render thread/INFO] [raised/]: Registering mod element: create:toolbox above minecraft:hotbar
[18Oct2023 20:15:13.552] [Render thread/INFO] [raised/]: Registering mod element: artifacts:helium_flamingo_charge above minecraft:air_level
[18Oct2023 20:15:13.555] [Render thread/INFO] [raised/]: Registering mod element: supplementaries:quiver_overlay above minecraft:hotbar
[18Oct2023 20:15:13.556] [Render thread/INFO] [raised/]: Registering mod element: irons_spellbooks:cast_bar below minecraft:hotbar
[18Oct2023 20:15:13.556] [Render thread/INFO] [raised/]: Registering mod element: irons_spellbooks:mana_overlay above minecraft:experience_bar
[18Oct2023 20:15:13.557] [Render thread/INFO] [raised/]: Registering mod element: irons_spellbooks:spell_bar above minecraft:experience_bar
[18Oct2023 20:15:13.557] [Render thread/INFO] [raised/]: Registering mod element: irons_spellbooks:imbued_spell above minecraft:experience_bar
[18Oct2023 20:15:13.560] [Render thread/INFO] [raised/]: Registering mod element: forbidden_arcanus:flight_timer above minecraft:experience_bar
[18Oct2023 20:15:13.560] [Render thread/INFO] [raised/]: Registering mod element: forbidden_arcanus:sanity_meter above minecraft:experience_bar
[18Oct2023 20:15:13.560] [Render thread/INFO] [raised/]: Registering mod element: forbidden_arcanus:obsidian_skull above minecraft:experience_bar
[18Oct2023 20:15:13.561] [Render thread/INFO] [raised/]: Registering mod element: overflowingbars:toughness_level above minecraft:mount_health
No performance issues now?
I knew going into this what I was doing before wasn't the right way to go about it, but I didn't expect it to tear your performance in half like that! I'm honestly impressed.
One more change to make is to move the extended support check out of the actual register event to the render event. That way you can toggle it on and off without restarting the game.
https://github.com/yurisuika/Raised/actions/runs/6565333500
There, the logger has been removed by the way so don't worry about that.
Spark client report: https://spark.lucko.me/VXWCObGDV8
With the mod I have around 55 - 75 FPS Without it I'm between 100 - 230 FPS