Jump to content

Question on multithreading in Minecraft.

Gat Pelsinger

I never play Minecraft without any optimization mods. Today I thought to play without mods and my experience was horrendous. One thing that I always notice in Minecraft Java with or without mods is that there are always lag spikes as soon as chunk updates are called. This problem though, just DOES NOT exist in Minecraft Bedrock, where no matter how garbage of a CPU you have and no matter how many chunk updates you call, that game just never stutters. With the slightest of my programming knowledge, if the world generation is decoupled with the render and world thread, how would the game possibly stutter? And if that isn't possible for some reason, then how does MC Bedrock does it better?

 

Also, there is a memory leak, not sure if it is a leak or just caching but Mojang, pls fix.

 

Microsoft owns my soul.

 

Also, Dell is evil, but HP kinda nice.

Link to comment
Share on other sites

Link to post
Share on other sites

What are your specs? I doubt it's a minecraft problem, more than likely it's a your system problem.

AMD 3600x, 16GB DDR4 3200MHz CL14, GTX 1080, and Ungodly Amounts of Storage

Link to comment
Share on other sites

Link to post
Share on other sites

Specs list? Nothing we can really do or recommend without knowing what you're working with hardware wise.

Main Desktop: CPU - i9-14900k | Mobo - Gigabyte Z690 Aorus Elite AX DDR4 | GPU - ASUS TUF Gaming OC RTX 4090 RAM - Corsair Vengeance Pro RGB 64GB 3600mhz | AIO - H150i Pro XT | PSU - Corsair RM1000X | Case - Phanteks P500A Digital - White | Storage - Samsung 970 Pro M.2 NVME SSD 512GB / Sabrent Rocket 1TB Nvme / Samsung 860 Evo Pro 500GB / Samsung 970 EVO Plus 2tb Nvme / Samsung 870 QVO 4TB  |

 

TV Streaming PC: Intel Nuc CPU - i7 8th Gen | RAM - 16GB DDR4 2666mhz | Storage - 256GB WD Black M.2 NVME SSD |

 

Phone: Samsung Galaxy Z Fold 4 - Phantom Black 512GB |

 

Link to comment
Share on other sites

Link to post
Share on other sites

@ItTakes2ToMango @SpookyCitrus

What? I really don't get your comments.

 

You really say specs is the problem when some performance mods give me like I don't know, maybe over 50% more performance or even more? This is a completely programming problem and it shows that Mojang's code is inferior in terms of optimization. This is a programming topic and hardware performance should not even be accounted. Having a really fast system which tears through the heap of unoptimized code doesn't mean "oh yeah, this game's great".

 

If you are still curious, I have an i5 10210U and integrated graphics. But this should not matter has people even with i9s and 4090s get huge performance improvement using performance mods. And upon that, if you still think it's a specs problem, I have seen benchmark videos in which Minecraft stutters sometimes on a 13600K, even with some performance mods. I have seen a lot of youtubers who had older systems and Minecraft stuttered on that too (like a n i5 7600).

Microsoft owns my soul.

 

Also, Dell is evil, but HP kinda nice.

Link to comment
Share on other sites

Link to post
Share on other sites

did you by any chance crank view distance somewhere beyond 12 chunks? because java is rather limited in the efficiency department in several ways..

 

besides - client side rendering is *fairly* multithreaded these days, but java is just java, and java is at best half the speed of C++.

 

sidenote.. i'm a minecraft java person, and unless i get really fancy with mods i dont really have stutters, but i always run my little collection of optimization mods.

 

as for "how" the game stutters - minecraft java is a REALLY strange codebase for a game, and while the optimization mods make a huge difference - the assumption mojang can just take these ideas and "plonk" them into the game without potentially breaking stuff is very shallow. this is A LOT of effort for something that is "suboptimal" but not broken.

besides - minecraft java has already come a really long way in terms of performance.. but there's just a point of diminishing returns, and that point comes A LOT sooner for java than it does for C++, and it comes A LOT sooner for paid developers than for a community passion project.

 

on that note.. do you also complain that any of these games may have stutters?

- rust

- conan exiles

- gmod

- scrap mechanic

- raft

- <insert other sandbox game here>

(aside from rust, i've played all of those, and had plenty of stutters in all of those.)

 

in a sense.. minecraft bedrock is unique in it's ability to not occasionally stutter.

Link to comment
Share on other sites

Link to post
Share on other sites

44 minutes ago, Gat Pelsinger said:

You really say specs is the problem when some performance mods give me like I don't know, maybe over 50% more performance or even more? This is a completely programming problem 

 

 

No, it does not outright indicate a programming problem.

 

44 minutes ago, Gat Pelsinger said:

it shows that Mojang's code is inferior in terms of optimization.

They don't make the game to be modded, so how a mod affects performance has nothing to do with Mojang's code optimization.

 

44 minutes ago, Gat Pelsinger said:

This is a programming topic and hardware performance should not even be accounted.

It's a stuttering issue, after you added mods, which increases how much power your machine will need to use for the game. We're fairly certain that you are not sure what you're talking about so we are trying to help you steer this in the right direction.

 

44 minutes ago, Gat Pelsinger said:

If you are still curious, I have an i5 10210U and integrated graphics. But this should not matter has people even with i9s and 4090s get huge performance improvement using performance mods. And upon that, if you still think it's a specs problem, I have seen benchmark videos in which Minecraft stutters sometimes on a 13600K, even with some performance mods. I have seen a lot of youtubers who had older systems and Minecraft stuttered on that too (like a n i5 7600).

Yeah.... and it looks like we're probably right. I'm not really even sure what you're trying to say here, but you're stuttering issue is more than likely due to your weak CPU and iGPU. Of course people with much better specs are less likely to stutter.... Them getting a performance boost from a performance mod and you not does not really indicate much of anything. That could be a difference in you having enough RAM or VRAM, and very likely is lol

 

It's definitely got nothing to do with programming....

AMD 3600x, 16GB DDR4 3200MHz CL14, GTX 1080, and Ungodly Amounts of Storage

Link to comment
Share on other sites

Link to post
Share on other sites

11 minutes ago, ItTakes2ToMango said:

It's definitely got nothing to do with programming....

oh.. it's got a lot to do with programming.. it's just also an inherit problem in every sandbox game that you have to account for all the stupid things your user may do, so there's a relatively high amount of software stack to get trough before rendering a frame. the fact that the bowl of spaghetti that java edition calls an "engine" doesnt particularly like intel graphics is just the cherry on top for OP here.

 

like i said above - in the comparison, bedrock not stuttering is more of an outlier than java's stuttering.

Link to comment
Share on other sites

Link to post
Share on other sites

34 minutes ago, manikyath said:

oh.. it's got a lot to do with programming.. it's just also an inherit problem in every sandbox game that you have to account for all the stupid things your user may do, so there's a relatively high amount of software stack to get trough before rendering a frame. the fact that the bowl of spaghetti that java edition calls an "engine" doesnt particularly like intel graphics is just the cherry on top for OP here.

 

like i said above - in the comparison, bedrock not stuttering is more of an outlier than java's stuttering.

Not what the user is trying to reference though? That has nothing to do with programming

 

The fact that a i9/4090 combo is getting a performance boost from mods that the i5/iGPU is getting a performance decrease from is very, very unlikely to have anything to do with the programming.

 

Stuttering in general is another thing

AMD 3600x, 16GB DDR4 3200MHz CL14, GTX 1080, and Ungodly Amounts of Storage

Link to comment
Share on other sites

Link to post
Share on other sites

6 hours ago, Gat Pelsinger said:

@ItTakes2ToMango @SpookyCitrus

What? I really don't get your comments.

 

You really say specs is the problem when some performance mods give me like I don't know, maybe over 50% more performance or even more? This is a completely programming problem and it shows that Mojang's code is inferior in terms of optimization. This is a programming topic and hardware performance should not even be accounted. Having a really fast system which tears through the heap of unoptimized code doesn't mean "oh yeah, this game's great".

 

If you are still curious, I have an i5 10210U and integrated graphics. But this should not matter has people even with i9s and 4090s get huge performance improvement using performance mods. And upon that, if you still think it's a specs problem, I have seen benchmark videos in which Minecraft stutters sometimes on a 13600K, even with some performance mods. I have seen a lot of youtubers who had older systems and Minecraft stuttered on that too (like a n i5 7600).

Didn't mean any disrespect if that's how you took my asking for your specs. It's a simple, straight forward question to gauge more insight into the situation and issue, you have been asking questions about this in several different sub forums all day. Your post here also specifically mentions multithreading which is directly hardware linked. I'm not trying start anything or hurt your feelings(which is what your reply makes me think you thought of for us asking for specs, I'm not here to judge) I'm just trying to help and understand more about what you need help with. If you had your specs properly listed on your profile in the first place not just some BS joke answers and telling users to fuck off, we wouldn't have needed to ask. 

 

Having heavily modded games in the past including Minecraft  myself, I know that sometimes mods(especially performance mods) can is some cases have issues with different hardware and components as well as configurations and even other mods. As for why Minecraft Bedrock runs better, it's the version of Minecraft designed to run on Mobile and Consoles, so it is already designed to perform better on mobile(smart phone) processors, APUs, iGPUs and the like. Java Edition Minecraft is inherently harder to run which is why it not only has higher spec requirements but also is only available on PC. That is why it isn't available for consoles and mobile devices. The game runs poorly on your system without the performance mods because of the system itself, not some rogue or messed up code, the same reason it's even worse on the i5-7600 you mentioned when compared to yours, that is simply just how the hardware works. The lower the hardware the lower the performance. Again, I'm not saying it isn't a "code issue" with Java Edition, but it's not likely. The whole point for Bedrock in the first place was for that specific reason. The issues you have brought up in this post and the others you have made clearly show this as a performance issue related to hardware. And again, to be super clear, I am not trying to belittle or judge anyone from what they have or can afford, it's just the facts of the matter. You're better off upgrading your PC, something as simple as a basic dedicated GPU, a 1050ti, 1650, something to take the load off of the iGPU and give you dedicated VRAM, would be much more beneficial than spending anymore of your time trying to find a code issue or waiting for Mojang to do something about Jave Edition. 

 

If you'd like the information from a trusted source here is the official list of differences between the two editions from the Mojang help page, keep in mind to read through it and see the performance related differences between the two. As well as maybe look into the required specs to run both editions if you feel so inclined.

https://help.minecraft.net/hc/en-us/articles/360058534412-Differences-Between-Minecraft-Java-Edition-and-Minecraft

Main Desktop: CPU - i9-14900k | Mobo - Gigabyte Z690 Aorus Elite AX DDR4 | GPU - ASUS TUF Gaming OC RTX 4090 RAM - Corsair Vengeance Pro RGB 64GB 3600mhz | AIO - H150i Pro XT | PSU - Corsair RM1000X | Case - Phanteks P500A Digital - White | Storage - Samsung 970 Pro M.2 NVME SSD 512GB / Sabrent Rocket 1TB Nvme / Samsung 860 Evo Pro 500GB / Samsung 970 EVO Plus 2tb Nvme / Samsung 870 QVO 4TB  |

 

TV Streaming PC: Intel Nuc CPU - i7 8th Gen | RAM - 16GB DDR4 2666mhz | Storage - 256GB WD Black M.2 NVME SSD |

 

Phone: Samsung Galaxy Z Fold 4 - Phantom Black 512GB |

 

Link to comment
Share on other sites

Link to post
Share on other sites

@SpookyCitrus @ItTakes2ToMango

 

I don't want to call you spoiled gamer dudes who laugh on others who are having problems with their low end PC and where it is running buttery smooth on your 20 billion dollar NASA PC. Again, this was a joke and I don't want to offend anyone or be racist to someone having a higher end PC, not like it's their fault, no no. I don't think you still know what exactly I meant. Sure obviously, slow PC slow performance, better PC better performance, ez right? But a faster PC brute forcing through unoptimized code just to show optimal performance is not a neat way of programming. Remember, this is a programming topic, not a gaming topic, and I see this from a programming perspective.

 

The reason I can point out openly about Minecraft's performance is because performance mods exist and are proof of how Mojang's code isn't the best optimized, but after @manikyath shared his opinion, yes, I do agree as for a billion dollar company focus on new content and features rather than focusing on something this is not completely broken and won't plummet their sales or something (performance I am talking about).

 

Also, did I miss something? Why are you two saying performance mods not giving me better performance than other's system or degrading my performance? I clearly stated that performance mods increase my performance by a lot and that is why I am talking about original Minecraft's performance.

 

Well at least somebody isn't spoiled understands my question. @manikyath having a 5800x still agrees with me that Minecraft's code isn't the best optimized and that is a programming issue.

 

First of all, we are going completely off tracks here. I never meant to criticize Mojang for having bad performant code (although I will be criticizing indirectly in the background). From a programming perspective, I just asked one question. Is the problem that everything is running one program thread and that decoupling the world generation thread with the render thread increase performance? And if MC Bedrock has better performance, HOW does it do it? What special sauce does it use to not stutter? I needed people with more programming experience like @Kilrah and @Eigenvektorto reply.

Microsoft owns my soul.

 

Also, Dell is evil, but HP kinda nice.

Link to comment
Share on other sites

Link to post
Share on other sites

Don't know anything about Minecraft, but if there are mods that improve performance your best bet at finding out what is limiting perf is to look at how they improve it. 

F@H
Desktop: i9-13900K, ASUS Z790-E, 64GB DDR5-6000 CL36, RTX3080, 2TB MP600 Pro XT, 2TB SX8200Pro, 2x16TB Ironwolf RAID0, Corsair HX1200, Antec Vortex 360 AIO, Thermaltake Versa H25 TG, Samsung 4K curved 49" TV, 23" secondary, Mountain Everest Max

Mobile SFF rig: i9-9900K, Noctua NH-L9i, Asrock Z390 Phantom ITX-AC, 32GB, GTX1070, 2x1TB SX8200Pro RAID0, 2x5TB 2.5" HDD RAID0, Athena 500W Flex (Noctua fan), Custom 4.7l 3D printed case

 

Asus Zenbook UM325UA, Ryzen 7 5700u, 16GB, 1TB, OLED

 

GPD Win 2

Link to comment
Share on other sites

Link to post
Share on other sites

47 minutes ago, Gat Pelsinger said:

Well at least somebody isn't spoiled understands my question. @manikyath having a 5800x still agrees with me that Minecraft's code isn't the best optimized and that is a programming issue

thanks for COMPLETELY misquoting me..

 

it's not a minecraft java coding issue. it's a common problem in sandbox games, and the java language not being as performant as C++ amplifies this inherent performance issue of sandbox games.

 

the 5800x alleviated a lot of performance troubles coming from a 4790k before that, but java is still java.

Link to comment
Share on other sites

Link to post
Share on other sites

19 hours ago, Gat Pelsinger said:

With the slightest of my programming knowledge, if the world generation is decoupled with the render and world thread, how would the game possibly stutter? And if that isn't possible for some reason, then how does MC Bedrock does it better?

Do you know these threads are decoupled, or is this speculation? I don't know the game's code base, nor anything about its engine, so I can only speculate here. I would say it's safe to assume that (a) synchronization point(s) between these two must exist.

 

The first thing that comes to my mind is that the Java code base is much older, so it may contain less than optimal legacy code that is difficult or even impossible to rewrite (without breaking backwards compatibility or simply deemed too costly/risky), where they were able to Do It Right™ when it was ported (rewritten from scratch?). Maybe they managed to get rid of some synchronization points present in the Java code, that don't exist in the C++ port.

 

Microsoft's documentation also states there are differences in the world format of these two editions. This could allow for optimizations in Bedrock that simply aren't possibly in the Java edition without breaking backwards compatibility.

 

As @manikyath said, Java itself can be an issue. It runs inside a VM, which has some performance cost, you can't do some low level optimizations available in C++, and last but not least, it comes with a Garbage Collector. That means there is a background worker that periodically frees unused memory and developers have no direct control over when this happens.

 

While this makes some things simpler (i.e. you can instantiate objects and pass them around without having to keep track who owns them), it does come with a performance penalty. C++ is more difficult in that regard, because you have to explicitly free memory you've allocated, but in return you get to control when and where this happens.

 

I also don't know how much knowledge transfer there is between the developers of Java and Bedrock. It could simply be that Microsoft's development team is more experienced when it comes to game development and they've included optimizations the other team doesn't know about/never thought of.

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Eigenvektor said:

 

The first thing that comes to my mind is that the Java code base is much older, so it may contain less than optimal legacy code that is difficult or even impossible to rewrite (without breaking backwards compatibility or simply deemed too costly/risky), where they were able to Do It Right™ when it was ported (rewritten from scratch?). Maybe they managed to get rid of some synchronization points present in the Java code, that don't exist in the C++ port.

behind the scenes bedrock is essentially a completely different game. they're doign an amazing effort at making it walk like a minecraft and quack like a minecraft, but once you go into the more edge case mechanics, it is a completely different game.

 

bedrock's origins lay with the mobile app version of the game, and it's basicly a C++ game from scratch. at the face of it there is mostly feature parity, but everything behind the scenes is fundamentally different, and essentially has had the benefit of being made "with hindsight".

Link to comment
Share on other sites

Link to post
Share on other sites

9 minutes ago, manikyath said:

…and essentially has had the benefit of being made "with hindsight".

Pretty much what I was thinking.

 

I'm sure there are areas in the original code that are problematic simply because the game now includes features that it wasn't originally designed to support (or never got features that originally sounded like a good idea). If you already know what you need (and don't need) it can allow for a cleaner and easier to maintain architecture.

 

For example, I know we have areas in our own code that are needlessly complex simply because they were designed to be (too) flexible. People envisioned all kinds of crazy use cases for them. Years later it turns out we only ever needed X, so you could greatly simplify the code. But of course a rewrite is time consuming, has potential dangerous side effects (and not everything is covered by tests), might accidentally break other stuff, would touch a lot of code and works generally well enough. So it simply never happens.

 

If there was a "v2" of our code base, I'm sure a lot of things would be done differently (which doesn't always guarantee they turn out better).

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

13 hours ago, Eigenvektor said:

Pretty much what I was thinking.

Yea same.

 

Overall I would suspect they got locked into what they initially created and it's just too much work while breaking compatibility to "fix" things.  Everything is 20/20 in hindsight afterall.  I don't think it was really meant to be as big as it currently is (or rather the initial idea of Minecraft wasn't) so you end up with design choices made that sort of limit how good performance it is.

 

It wasn't made originally when multi-threaded games were an expected thing.

 

I agree with what you said, that sometimes you get over complicated code to do things that you don't really need that much flexibility to do, but I think in Minecraft's case it might be that they didn't think it would be this expanded upon so you have patchwork on patchwork.

 

I so know the pain of spending a week writing a really neat parsing code, where I could add in extra features at a drop of a hat and ultimately it goes mostly unused (I have added a couple, but about 90% of the code that makes it so flexible isn't used and isn't even exposed on the GUI layer).

3735928559 - Beware of the dead beef

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×