TeamPneumatic / pnc-repressurized

A port of PneumaticCraft to MC1.12+
Other
121 stars 50 forks source link

Drone on charging station causes lag when nearly full. #596

Closed duncanwebb closed 3 years ago

duncanwebb commented 4 years ago

Minecraft Version

1.15.2

Forge Version

31.2.36

Mod Version

pneumaticcraft-repressurized-1.15.2-1.4.4-64

Describe your problem, including steps to reproduce it

Placing a redstone block next to a charging station and the charging station is set to emit a redstone signal when charging. When a drone is nearly charged either on or in this charging station the lamp toggles on and off and causes a lot of lag. The compressors are active so the pressure is rising and the drone equalizes the pressure.

Any other comments?

This will mostly happen with basic pressure as the pressure is lower than that of the drones maximum.

desht commented 4 years ago

Sorry, what lamp are you referring to? Can I see a screenshot of your setup?

duncanwebb commented 4 years ago

charging-station A redstone lamp but a picture is always good, could make an animated gif if you need it.

duncanwebb commented 4 years ago

lag-from-drone-charging

See the frame rate drop completely to 6 fps. The charging can take 30 seconds depending on or what is happening.

I have the feeling that since Minecraft 1.14 modded Minecraft is generally very laggy. I was standing on the roof of my mob farm that is y 240 and the frame rate drops below 60 to 54 fps (Dxtory prevents frame rates above the display refresh rate) and there are no mobs in the farm.

desht commented 4 years ago

Not seeing the flashing behaviour here. When a drone (or me, with pneumatic armor using up air) is on top of the charging station, the lamp just stays on. I don't know why it's toggling like that for you.

In any case, the lag is vanilla, not PNC - any regular block updates will incur a performance penalty, and frequently updating light sources will incur a big performance penalty, as you've spotted. Flashing lights murder FPS and TPS, and always have.

I also just tried (in 1.16) a redstone lamp with a Redstone Module & Advanced PCB set to "Clock" mode - on 2 ticks, off 2 ticks, and it also didn't flash the lamp or cause any FPS drop (mine stayed at ~90 fps): https://streamable.com/v198td

duncanwebb commented 4 years ago

The flashing behaviour does happen, I promise but might be tricky to reproduce. It only happens when the drone is near to 5 bar.

The coal compressors are set to be enabled when they receive a low redstone signal, so they burn off the remaining coal when the pressure reaches 4 bar giving a peak pressure at about 4.8 bar. When the refinery is running, the regulator tube is receiving a redstone signal of 11 allowing 1.3 bar to hear the refinery. At some point the pressure is rising slowly the drone is fully charged, then the pressure has increased enough for the drone not to be fully charged. There are 4 speed upgrades in this charging station (this might be significant). Guard drone stay on the charging station when they are full.

What pressures do drones decide to go to the charging station and leave it? What pressure difference is the drone considered fully charged.

Here is the full setup for this charging station.

three-compressors

This station has six speed upgrades.

charging-one-compressor

I'm not sure what you can do about this, some possibilities are:

I could try the following:

duncanwebb commented 4 years ago

Here is another clip to show it is not so random lag-from-drone-charging-2

duncanwebb commented 4 years ago

What's happening here, is the pressure gauge tube module acting like a block?

It is a bit crowded there anyway, so I'll move the charging station away.

desht commented 4 years ago

"is the pressure gauge tube module acting like a block?". Not sure what you mean by that. The module is part of the pressure tube block & tile entity, not a block in its own right. But the pressure tube itself is a redstone-emitting block (i.e. it emits redstone when a module on its tile entity tells it to).

But yeah I'm entirely unsurprised at the low frame rates in your image above. Vanilla redstone is notorious for causing massive cascading block updates when it flips, and PNC is not at fault for that. You could try using Redstone Modules on tubes to replace both the vanilla redstone and the repeaters - far fewer block updates will happen.

To answer some earlier questions:

Another possibility to reduce lag here is for me to add a "dampener" on the charging station redstone output, i.e. don't allow the redstone output to flip more than once every (say) 10 or 20 ticks. That could also help.

But do try replacing your vanilla redstone with redstone modules; they're not too expensive, and for simple signal transmission they don't need an Advanced PCB. Helpful tip for compactness: if you put a Pressure Gauge and Redstone Module (output mode) on the same piece of tube, the Redstone Module will be able to emit the Pressure Gauge's signal level.

desht commented 4 years ago

Actually, thinking about it, redstone modules mightn't be so useful here, since the circuit depends on vanilla redstone signal decay to work, and redstone module signals don't decay over distance :(

In any case, I'll be pushing an update shortly with the "dampener" code, which I hope will help...

desht commented 4 years ago

Give build 68 a go when you get a chance. Hopefully it'll perform better. Charging station redstone output won't flip more than once every 10 ticks now.

duncanwebb commented 4 years ago

What I mean was in the last animated gif the redstone signal from the charging station is pulsing the redstone signal from the pressure gauge tube module. I didn't expect this but the tube is powered then it is clear why. Many thanks.

10 ticks is a bit too quick, 20 ticks would be better.

BTW, even pulsing a redstone repeater caused a highish lag 60 to 42 fps. I have a clip showing this if you need it.

I'll try a redstone module as the redstone decay is used to control the compressors. This is just an indicator to show that a drone is charging.

After installing the new version, again many thanks for this, there are quite a few drones lying around with no pressure. This is odd as they recharge themselves fairly often.

desht commented 4 years ago

there are quite a few drones lying around with no pressure

Sounds like they can't get to a charging station? I haven't changed anything relating to pathfind or charging, so I think that's a coincidence.

10 ticks is a bit too quick, 20 ticks would be better.

Need to be careful about making the interval too long, or automated systems run the risk of inaccurate redstone signals messing up the automation, but I could make this a configurable, I suppose.

duncanwebb commented 4 years ago

The drones are normally charged and recharge when needed, I can't figure out what causes them to run out of pressure. I have observed that sometimes they don't go to the nearest charging, even when it is free but it teleports off to another charging station.

A better way to prevent the charging causing he redstone signal to toggle on and off. Add speed upgrades into the compressors to match the charging station's speed upgrades. When having many things off the same compressor then it is a balancing act.

desht commented 3 years ago

Think the major cause of lag was addressed in 2.8.1 - closing this.