Mekanism

Mekanism

111M Downloads

[1.12.2]Poor FPS from entire mekanism

Tommeh1 opened this issue ยท 29 comments

commented

Even with the machine effects, lighting etc turned off, everything from mekanism has a massive impact on fps, much more than any other mod, machines, pipes, bins, doesn't matter.

Forge: 14.23.5.2811
Mekanism: 1.12.2-9.6.3.355(and many older versions had the same issue)

commented

Yup that's what I was after. It does correlate with the LG display of Logistical transporters being a contributor, but when you drill down into it, it seems to be spending most of its time in Storage Drawers code (while calculating if it can take a stack)

image

commented

I'll provide evidence for it somewhere next week, same for all my other issues

commented

You both seem to be nailing down on TPS but the original complaint was FPS? Going to need a visual VM log of the client instead of the server. That way we can check for visual rendering issues. Which I know mekanism has had in the past.

commented

Yup that's what I was after. It does correlate with the LG display of Logistical transporters being a contributor, but when you drill down into it, it seems to be spending most of its time in Storage Drawers code (while calculating if it can take a stack)

image

If I remove the offending single mekanism logistical transporter set to pull, this goes away. I don't know if there is anything mekanism can do to alleviate the frequency that this is hitting tps.

For example, Storage & Drawers only allows a certain items to be inserted into the system at a time (meaning mekanism pipes pulling from a vanilla chest with many items will only attempt to insert a couple of items at a time even though it can pull items faster).

I get what you are saying about the Storage & Drawers code, but this lag makes this mod (mekanism) unusable in a multiple setting (even in a single player setting). I will force players to find other solutions to transport items that won't lag the server. I will either have to ban the logistical transporters or the mod itself (I mainly included mekanism because of the logistical transporters, although a lot more than that is currently being used from the mod on the server).

commented

You both seem to be nailing down on TPS but the original complaint was FPS? Going to need a visual VM log of the client instead of the server. That way we can check for visual rendering issues. Which I know mekanism has had in the past.

I'm betting the original poster is actually losing TPS (not FPS). FPS is always low when connecting to worlds but recovers within seconds typically. This isn't specific to any mod really, it just needs to load chunks. The more that is in those chunks, the longer it takes to load.

Either way, let me know and I can open a separate issue. This is a real problem that affects whether this mod should be included in any modpack. With this issue, it seems that either some items need to be banned or the mod should not be included in mod packs. S&D and Mekanism are common enough mods (in a lot of packs) that this interaction should probably be fixed to not constantly lag the server. These logistical transporters need to use about two or three orders of magnitude less server time...

commented

I'd appreciate some evidence or a reproduction setup for this, as otherwise its a very broad issue / deep rabbit whole / lots of guesswork.

commented

Although unrelated to the original poster, I would give the following feedback, which I have verified with Lag Goggles (see attached screenshot):

  • item pipes (logistical transporter) connecting to normal inventories to push consume a fair (but liveable) amount of TPS.

  • Item pipes connecting to storage & drawers (to pull) consume a RIDICULOUS amount of TPS... makes my server lose ticks constantly when players are logged into the game. Let me know what I can do to give evidence of this.This particular storage & drawers has around 60 different items to potentially pull. Basically, one storage & drawers inventory system connects to a crafting system. Mekanism logistical transporters connect these systems.

Selection_087

commented

Even with the machine effects, lighting etc turned off, everything from mekanism has a massive impact on fps, much more than any other mod, machines, pipes, bins, doesn't matter.

Forge: 14.23.5.2811
Mekanism: 1.12.2-9.6.3.355(and many older versions had the same issue)

Are you playing on single player? Is there any way to see the internal server tick rate in single player? I wonder if you are actually seeing WORLD tick loss.

commented

@texaswriter I need to find a proper guide I can add to the issue template, but the most helpful thing is an .nps file - my go to is VisualVM.

It needs to have valid CPU usage time from a CPU profiling found on the Sampler tab. Take a snapshot to save.
image
image

commented

Here is a snapshot profiler. Can you read this? I can't find most of the mods impact like I can see with Lag Goggles.
snapshot-1552806307397.nps.zip

commented

Here is another snapshot profiler (if it is helpful). I found out you can search within the results to find the mods.
snapshot-1552807485862.nps.zip

commented

I likely know the spot that is the problem. I think I recall opening a ticket a while back pointing out how mekanism pipes bypass insert checks. As well do not map source to output very well. Its something I'm planning on pull requesting over the next 2 months.

I suspect there is also a memory churn problem with the pipes as well. It was something I patched out in 1.7.10 for our custom server. I think I can replicate the same fix but no promises as I'm short on time. Though this will be up to thiakil to pull in once I make the changes. As I'm not a developer on the mod, only looking at the problem to get voltz modpack updated.

commented

Thanks for the response. Yeah, any help would be appreciated. I really like Mekanism (comparable enough to IC2 as far as balance). Since BC has been without a stable release since 1.7.10 (or so), there are less options with item pipes. It's nice having a mod like Mekanism that touches all the important areas of tech/power.

commented

Heh I guess I missed that this particular thread was supposed to be about fps, but as you say visualvm is useful for that too (I automatically went for the server thread since the poster mentioned the transporters)

There is of course probably room for improvement on the transporters, and I will take a look as well in the meantime :)

commented

As part of the 9.7.0 release all the performance improvements from Mekanica are now included. I am interested in seeing if the performance you guys are seeing is any better. https://minecraft.curseforge.com/projects/mekanism/files/2698323

@texaswriter I believe if you try again with your setup and using laggoggles you should see that the impact of logistical tranporters are now a lot lower. If you could confirm that it would be great.

commented

I'm not see any improvement in FPS moving from 1.12.2-9.4.13.349 to 1.12.2-9.7.2.373
Attached image of avg fps and then looking at Mekanism machines running.
2019-04-24_21 45 08
2019-04-24_21 45 42
2019-04-24_21 46 20

commented

A profiler snapshot for the client would be useful there, otherwise its hard to nail down what the issue is - especially as you've got more than just Mekanism blocks there

commented

Might also be useful to rule out other mods that might be the source. Can you repeat your test without AE2, TE, and any other mod other than mekanism. As both of those mods have real time renders for cables that could be an impact. Try also using a profilier mod that might give more insight into your client's runtime.

commented

Lag goggles is not the definitive source of information on what's causing lag as it does not have the granularity required (the pipes calling into other mods is lumped under the pipes' entries), and only really reports times relative to other mods

commented

No, I get that. But it is in the realm of "close enough" for:
a) knowing if there is a problem (if minecraft sheep are the # 1 issue, I know I'm fine unless there are 10M sheep).
b) knowing what is the biggest problem. If mekanism logistics pipes are 95% of the server time.... If I have a TPS issue, then I know what it is and by how much...
c) Moreover, lag goggles is AMAZING at visualizing this and tracking it down to a specific entity/block. It will let you teleport to the exact offending entity/block (great tool for a server op).

Obviously if you are talking about debug, stack-trace, etc., I am sure there are much more specific (granular, as you say) tools for this. For a layman server OP or admin, the lag goggles tool is good enough to understand configurations of blocks/entities and/or specific blocks/entities that are causing issues.

commented

I appreciate ya'll attention to these. It will really help the Mekanism community when there are fixes and improvements. I'm glad to see all the fixes that have come in the last month or so!! Great job!!

I just had some bad luck with the timing of the releases, which caused me to replace with different item pipes. And to be clear, the recent fixes did improve it so it wasn't causing me to lose tps. I'm sure it would have been even better with more recent fixes. I still have Mekanism logistics pipes in other parts of the world. I will report an updated lag goggles screenshot from those. None of the other ones were as bad (smaller systems), but I can give an estimate of how much better.

commented

I'd agree with that in cases of entities and single blocks, but definitely not for pipes as there are far too many variables, owing to the fact that they need to call into a bunch of other mods. Even meks auto eject function runs into this

commented

I see what you are saying... like if another mod's time gets reported as mekanism.

commented

Exactly, it's kinda like taking your pc to a repair shop and when they ask you what's wrong you just say "idk it's just slow, fix it" - eventually it might get solved but there's a lot of work that's involved in working out what the problem actually is

commented

Okay. Thanks.

FWIW, here is a lag goggles screenshot from another area in the server with logistics pipes. Mekanism logistics pipes are way down at 1%!! Before a single mekanism logistics pipes (that was going in or out of any given inventory) was typically at 256 u-second/t with the ones going out of the S&D at 2.5K u-second/t.

Now I can't even find in the results... this is great.
Selection_004

commented

Fantastic news!

Another thing you'll notice there though is that the thermal dynamic pipes appear to do their processing on the tick event subscriber - mek does it on the individual pipe tile entity

commented

I'll work on getting profiler installed but in the mean time, I've notice the FPS lag is only happening when ore is processing running. I swapped to AE2 cabling thinking it was Mekanism pipes causing lag but it wasn't.

commented

@pupnewfster Unfortunately, I had a couple of problems with Mekanism from the last few updates since my previous comment here. I'll just mention my observations of the item pipes here. I'll see if there are any github issues for the other one.

Some of the lag from the Mekanism item pipes was lessened from a release made shortly after that. Which is to say that, before, the item pipes was causing the server TPS to constantly spike an (consistently well below 20 TPS). Afterwards, it wasn't causing my server TPS to spike (staying at 20 TPS), but lag goggles still reported that it was taking a lot of server time.

Because of this, I had to swap out to another mods item pipes. This mod doesn't seem to constantly poll. I think it uses a signal or event based approach. I still use as many Mekanism machines as I did before. I even still use the item pipes/conduits/etc in some smaller inventory systems.

This is not to say that Mekanism is 100% to blame here. I hooked Mekanism item pipes to a Storage & Drawers controller with many raw materials (e.g., ores, stones, etc.) and in-process goods (ingots, etc.). So probably mostly the combination of Mekanism and S&D in this large system is the big issue. With the new set with TF item ducts, I removed the controller and just piped to each S&D bin individually.

commented

Closing this as 1.15.1 has improved FPS for various things, and I have been making further improvements in it to also improve the TPS (which is what a lot of the discussion in this issue has led to).