mojira.dev
MC-126518

Redstone or lighting updates causing severe lag and framerate drops

Even basic redstone contraptions are causing severe lag and framerate drops. I typically get well over 100 FPS (redstone_clock_disabled.png). To duplicate, I created a simple redstone clock that toggles a number of redstone torches and dust. While active (redstone_clock_enabled.png), this causes my framerate to drop to about 25 FPS (using the bundled javaw.exe 1.8.0_25 my framerate drops to 5 FPS).

I think this may be a lighting issue, however. I tested a redstone contraption that does not create lighting updates with a piston and rapidly flipping the lever causes no lag. If I add a redstone lamp, the lag spikes return (redstone_lamp.gif). Ninja Edit: I also get a lag spike when placing and item in a furnace and it fires up.

This may be related to the issue reported here: MC-124086 which I believe has been erroneously marked DUPLICATE, as this bug is not present in Minecraft version 1.12.0.

Related issues

Attachments

Comments

migrated
[media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media]
migrated

Okay, yeah I went to the nether and started mining glowstone. I get a lag spike each time one breaks or is placed. I'm pretty confident it's the lighting updates.

migrated

I can confirm that lighting causes lag spikes in 18w15a.

I couldn't tell from testing whether this is client side or server side (or a little of both).

That .gif makes it pretty clear that there's an issue 🙂

pokechu22

This sounds like it could be a variant of MC-1692. Are you sure that this doesn't happen in 1.12.2?

migrated

No, it doesn't happen in 1.12.2. I actually went back to 1.12.2 because this bug makes playing with redstone contraptions unbearable.

Nergalic

The lag depends on the distance to the redstone circuit: If you go ~37 blocks away (Mipmap level 4) the lag spikes disappear entirely. See the attached screenshots:

  • 1 - Inactive - Close shows a simple (incomplete) redstone clock

    [media]
  • 2 - Active - Close shows the completed redstone clock causing FPS drops

    [media]
  • 3 - Active - Near shows the lag getting worse 6 blocks away

    [media]
  • 4 - Active - Far shows about the same lag 35 blocks away.

    [media]
  • 5 - Active - Better shows the lag getting better at 36 blocks away.

    [media]
  • 6 - Active - OK shows the lag completely gone at 37 blocks away.

    [media]

I was unable to reproduce the issue in an empty super flat world (Redstone Friendly preset), leading me to do testing in different environments:

  • The lag incurred seems to depend on the surroundings. The same circuit produces a lot more lag in a forest than on a plain mountain side for instance.

    [media][media]
  • I tried building the same circuit in a Roofed Forest and experienced massive lag. Setting my video settings to fast graphics reduced this considerably although it was still very noticeable. Here are screenshots with fancy vs fast graphics setting:

    [media][media]
  • The biome blend distance setting also makes a considerable difference in the severity of the incurred lag. See my next comment.

  • The lag is present even when the circuit is built in the middle of the chunk (see the forest screenshot above). It therefore doesn't seem likely to be caused by MC-1692.

Nergalic

I went back to 1.12.2 and repeated my testing with the circuit in different environments. My clock circuit also produces lag in 1.12.2 but the framerate drops are less severe (the spikes rarely go below 30 FPS).

Based on the lag severity changing with the video settings it could seem like the issue at least partially is related to rendering. With biome blending at 5x5 I get lag similar to what I have in 1.12.2.

Here is the same clock circuit in 1.12.2 (smooth stone), and in 18w19a with biome blending at 5x5, 15x15, and off:

[media]

[media][media]

[media]

I have placed a block of glowstone to avoid lighting changes, which makes a noticeable difference in itself:

[media]

[media]

What really puzzles me is that the lag goes away when the distance exceeds a certain threshold, even with fancy graphics and biome blending at 15x15.

Nergalic

As Tim Fellow notes, the lag also occurs when a furnace lights up.
Here is activation of a furnace in 18w19a on the beach and in a roofed forest respectively:

[media]

[media]

Screenshots are with biome blending at 15x15 and fancy graphics, the two video settings that I have found to affect severity of the lag spikes.

PhiPro

The heart of the problem is that "rebuildNear" (or whatever it is called in the profiler) became much slower in the 1.13 snapshots. It is the process of collecting data of a section that is then used by the GPU to render this section. This has to be done every time an update occurs in the section. For near sections, this is done on the main thread, sections that are farther away are rebuilt on worker threads. That's why the issue disappears when moving away from the contraption.

Redstone and light updates are just the easiest way to cause a bunch of sections to be rebuilt, but the underlying issue is completely unrelated to redstone and lighting. Sure, they cause a fair amount of lag by themselves, but that's another topic.
To see this, go in creative mode and spam click to destroy blocks (1-2 blocks per second). In the 1.13 snapshots, you will notice some spikes in the FPS graph, however they don't appear in 1.12.

Updates at chunk borders cause all adjacent sections to be rebuilt, so those updates have an even stronger effect on the issue. This is exactly MC-1692.

PhiPro

This issue also relates to MC-123584 and MC-123263 which are about the decreased performance of "rebuildNear" in the 1.13 snapshots I described above..

Nergalic

Still a problem as of Minecraft 1.13-pre2

LuxiKeks

Also an issue in pre3.

Nergalic

Still a problem as of Minecraft 1.13-pre4

migrated

Still an issue in 1.13 pre5.

migrated

Still an issue in 1.13 pre6.

migrated

I just tried this again in pre6 (redstone_lamp_13pre6.gif). There's an improvement, but the issue is still definitely there.

migrated

Still an issue in 1.13 pre7.

migrated

Still a major problem in pre-release 8. Constant lag spikes on basic redstone.

migrated

Still an issue in 1.13-pre8.

@frank the frank
Don't say it's still an issue in a prerelease that isn't out yet. Wait for it to be out first and then test it.

migrated

Still an issue in 1.13-pre9.

migrated

Still an issue in 1.13-pre10.

migrated

Still an issue in 1.13.

R3mark

I've tested this in 18w30b, in a freshly generated world. I recreated the simple redstone circuit as shown in image 2 of the original post (repeater on 4 ticks).  With the redstone off, I get about 500 fps (no V-sync). Turning the circuit on drops the frames to about 440. Lighting up the redstone cuts the drop in half, to 470. 

In a populated world, this issue becomes a real problem. On my 1.12.2 multiplayer world, basic redstone has almost no noticeable impact on my fps (stable 160 fps at spawn), whereas the same map converted to 1.13 on a test server with the same specs as 1.12.2 main server, or even 18w30b in single player, consistently grinds to around 11 fps when the same redstone contraptions are activated. For this reason, we have not yet updated our server. 

Nergalic

Still a problem in v1.13.1-pre1

migrated

Confirmed for 1.13.1-pre2.

migrated

Still an issue in 1.13.1 release.

Nergalic

Sadly still an issue in 1.13.2 – but the 1.14 snapshot 18w44a looks promising with 60 FPS at v-synced fancy graphics, performing better than 1.12.2!

[media]

I also notice considerable improvement in larger contraptions, although the frame rate still is affected. I suggest prior commenters to rerun their tests in the snapshot and write back what they think so we can update the issue accordingly.

My personal experience with smaller circuits is that only light level changes cause a noticeable drop in the frame rate. The redstone circuits themselves have improved; lighting updates such as Tim Fellow's redstone_lamp_13pre6.gif are still problematic.

JUE13

Confirmed for 18w46a. This bug is very annoying and spoils the desire to play.

migrated

This issue affects 18w48b. The smoothness seems to have improved in the 1.14 snapshots compared to 1.13, but updating lighting still causes noticeable framerate drops.

migrated

Redstone causing lag seems to be almost entirely dependent on chunk geometry as in MC-123584. I tested in 19w13b, but is prevalent in all snapshot versions I've been playing recently. A simple observer clock causes massive frame time spikes in a chunk (or immediately next to a chunk) full of fences, but has very minimal effect on frame time one chunk over.

[media][media][media]
migrated

And since I apparently can't upload a new image when editing a comment, here is an extreme example of a super simple redstone clock next to a 10x10x10 cube of fences, which makes the game literally unplayable, with a greater than 100x increase in frame times.

[media]

migrated

(Unassigned)

Community Consensus

Performance

lag, light, redstone, rendering

Minecraft 18w09a, Minecraft 18w10a, Minecraft 18w11a, Minecraft 18w14a, Minecraft 18w14b, ..., Minecraft 1.13.1-pre2, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 18w46a, Minecraft 1.14.3

Retrieved