PneumaticCraft: Repressurized

PneumaticCraft: Repressurized

43M Downloads

Performance issues with Liquid Hoppers

kihira opened this issue ยท 14 comments

commented

Minecraft Version

1.12.2

Forge Version

14.23.4.2709

Mod Version

1.12.2-0.6.7-210

Describe your problem, including steps to reproduce it

Liquid Hoppers appear to cause quite an FPS drop in certain conditions that I'll try to explain below.
I have been talking to MineMaarten about this a little so he might also be able to provide some insight.

I've been using this mod on Forgecraft (server) and wanted to pull out the fluids from the Refinery and using Liquid Hoppers seemed like the best way. However I've been running into two issues with them, one appears to cause "micro stutters" (20-50ms freezes about every time the Refinery updates) and the other is a massive FPS decrease.

Micro Stutters

This appears to be caused by having hoppers feeding into each other. I've tried to reproduce this in a single player world but the issue isn't as noticeable, possibly as there isn't a lot of other stuff around. I have attached a screenshot of the example setup however.
image

FPS Drops

The next issue (might be related) is more full on FPS drops and it appears to possible be related to the fact that hoppers seem to accept input from their "output" side, almost being able to cause a loop.
image
In this screenshot I am using TD tubes however the issue can be replicated with any other liquid transport modes.

Any other comments?

I've tried this with the latest beta available on CF and the issues still seem to persist.

commented

I've made a collection of changes, which will hopefully improve things. In summary:

  • Fluid tanks were being synced to the client far too often; every time they changed. This would be particularly noticeable with the refinery, with 5 tanks changing little and often. I've changed fluid tank sync'ing so that updates are only sent to the client when the tank's contents change by more than 1% of the tank's total capacity (configurable - see D:liquidTankUpdateThreshold in pneumaticcraft.cfg)
  • I've altered liquid hoppers so they no longer accept fluids on their output side, and no longer allow extraction from their input side. Note this also applies to loading/unloading with buckets (so right-clicking the input face of a liquid hopper with an empty bucket will always open the GUI now, not extract fluid)
  • I've made use of our existing tile entity caching to get the neighboring tile entity more efficiently when transferring fluid (note that most PNC tile entities already use this, but the omni & liquid hoppers got overlooked..)

All these changes are in build 233 from http://jenkins.k-4u.nl/job/PneumaticCraft-Repressurized/ - I'd be grateful if you could test that and let me know...

commented

Ah so much better thank you!

I've only been able to test in SP for now but I'll try to get it in for when we next update the server and report if it's fine there too :)

commented

We got the latest build on the server but good news and bad news.

Second case with the input/output is good. Not having this issue anymore.

However the first case with liquid hoppers piping into each other seems to almost feel worse now. Before it was micro stutters but now it freezes far more frequently it feels like. It's hard to get a video of it but I can try tomorrow. We've kept it at the default value for syncing stuff and it shouldn't be updating that often (the refinery seems to do its thing about once a second).

I can ignore that issue as I can now just pipe out all into a IE pipe however it does seem like something is cascading when they pump to each other. I'll try and take a profile of it during it tomorrow and mess around more.

I've also got a crash report for you involving using other mods wrenches on pressure pipes but I didn't have time to upload it. I'll create a new issue for that in about 12 hours though once I can confirm if it is this mod at fault (or even if you support other mods wrenches haha)

commented

OK. I'll do some profiling myself but I've been having trouble with VisualVM locking up the instance so I'll need to find another profiler.

Regarding modded wrenches, I've had some compat issues in the past... a stack trace will be useful there. Right now a couple of other mods' wrenches are supported (TE & RFTools) but I have been meaning to add more.

commented

Quick question: is it client side FPS stuttering or server TPS lag that you're seeing?

commented

Certainly client side, doesn't seem to be causing any lower TPS but I'll ask if we're noticing a drop.

And I'll get that stack trace to you tomorrow (need to sleep now) :)

commented

Good stuff! By the way, v0.7.2 (beta) has just been approved on CF, and it has these changes (and although it's currently marked as Beta, it should be fairly stable - will probably get marked as Release if no serious problems are reported in the next few days).

commented

Certainly plausible! However shouldn't the tanks also switch rapidly between empty and not-empty when they still transfer to a pipe? It's a rather weird issue and it does almost sound like delayed sync would be the best solution. You could make it so every 10 ticks, it compares it to the last fill value from 10 ticks ago and if it's changed by x amount, send update? I don't think you need to sync the status more then twice a second honestly and players shouldn't notice much of a big difference.

commented

I think the FPS problem is due to the hopper tanks rapidly switching between empty and not-empty. While I optimised the case where the fluid level changes by small amount, a switch from empty to not-empty or vice versa counts as a change in the fluid type, which still always causes a sync to the client. So there are 4 refinery tanks and 4 hoppers spamming the client with fluid tanks sync updates every tick.

I need to find a way to "smooth over" those very brief switches from empty to not-empty, i.e. if it only spends a tick with fluid in it, avoid sending sync updates. Will need to have a think about this...

commented

I made a few more tweaks today and they're available for testing in build 235. Basically, tanks sync much less often now: every 10 ticks for switching from empty<->not empty, or for large (>1% capacity) fluid level changes, and every 40 ticks for small changes. This seems to be pretty smooth, but feedback is invited...

commented

My apologies for not responding, deadlines at work and tons of stress ^^;;

Yeah, I'll let you know anything else I come across. I think a lot of mods are having similar issues, I notice the same issues with the crafting table from TiCon etc.

Been having a ton of fun with the mod though, next up is trying to understand how to program drones haha

commented

I'd recommend viewing MineMaarten's old video series on YT (search "drone programming pneumaticcraft") - although they're for the 1.6/1.7 versions of Pneumaticcraft, the concepts still all apply - drone programming hasn't really changed since then.

commented

Going to mark this as closed, I think we're in fairly good shape here. Feel free to reopen if you experience any further performance issues with fluid tank syncing.

commented

Or DW's off course :)