News for hackers. Stuff that matters.
Re:Breaking the Limits: How Folia Made 1,000 Player Minecraf... by ohgodplsno on Tuesday June 27, 2023 @03:40AM (#36489994)
Minecraft Java used to allocate over 200MB/s per player when moving, and just 50MB/s when static. A lot of it stems back from Minecraft 1.8, where code was updated to take a BlockPos(float x, float y, float z) class instead of just (float x, float y, float z). Pretty much every single object in the game has to deal with its position. Millions of objects allocated per frame, only to be discarded later. Along with a looooot of other questionable choices. It's not even a runtime problem: you'd have the same issues free()'ing that memory on your own. Just stop allocating so damn much.

But then again, Notch never claimed to be a great programmer.

Re:Breaking the Limits: How Folia Made 1,000 Player Minecraf... by starlevel003 on Tuesday June 27, 2023 @03:42AM (#36490005)
the post-1.8 codebase awfulness has nothing to do with the source programmer. hell, by 1.13, the game had practically been rewritten at least once over.
Re:Breaking the Limits: How Folia Made 1,000 Player Minecraf... by phito on Tuesday June 27, 2023 @03:44AM (#36490022)
Just use a struct... Oh wait, Java does not have structs....
Re:Breaking the Limits: How Folia Made 1,000 Player Minecraf... by grishka on Tuesday June 27, 2023 @03:50AM (#36490067)
Yet.
Re:Breaking the Limits: How Folia Made 1,000 Player Minecraf... by mike_hearn on Tuesday June 27, 2023 @04:38AM (#36490397)
IIRC the introduction of BlockPos post-dates Notch. The style of just passing three floats around was his original style.
Re:Breaking the Limits: How Folia Made 1,000 Player Minecraf... by le-mark on Tuesday June 27, 2023 @06:58AM (#36491254)
Notch was well aware of the issues around allocating a lot of small objects in Java. He used to write 4k games with a byte code assembler. Implying technical knowledge of the platform was not the problem.
Re:Breaking the Limits: How Folia Made 1,000 Player Minecraf... by Pannoniae on Tuesday June 27, 2023 @07:39AM (#36491503)
Notchian code ran way better than modern MC - even though it used completely obsolete OpenGL 1.1 fixed-function calls.

They've upgraded to OpenGL 3 and shaders now; but the game's memory and CPU usage is through the roof with inconsistent performance and huge lagspikes.

Most of this is caused by utterly spurious and unneeded allocations; stream code on hot paths and complete overengineering and abstractions totally unfit for purpose. By that I mean heavy usage of inheritance and indirection in rendering code, and horrible memory wasting with vertex data. (Most things are full floats even if they could be packed and in some cases, even duplication of the same data due to bad data design)

Re:Breaking the Limits: How Folia Made 1,000 Player Minecraf... by kaba0 on Tuesday June 27, 2023 @07:59AM (#36491635)
Do you have any source for that? It seems questionable at best. Also, depending on where it is used, Java deals very well with indirect calls, it doesn’t have the same cost as, say, a C++ virtual call.
Re:Breaking the Limits: How Folia Made 1,000 Player Minecraf... by Pannoniae on Tuesday June 27, 2023 @09:37AM (#36492529)
Source for which section? I am basing this on mostly my experience and codedigging - I don't think there are many written sources about observing this other than anecdotes on forums or reddit or whatever.

With that being said, I'm happy to investigate in detail if you can tell which parts you are interested in.

You are right, the JVM has many optimisations built in to de-virtualise calls and avoid allocations and the such, but if you abuse it, the JIT will give up. I don't think any JIT will de-virtualise or perform escape analysis on 5-6 layers of indirection with branching.