3 ms·
I heard an anecdote about how Minecraft got much slower when Notch (the original developer) turned it over to a team of employees. The new team did some refacto
by majewsky 8y ago
I heard an anecdote about how Minecraft got much slower when Notch (the original developer) turned it over to a team of employees. The new team did some refactoring, e.g. instead of calling functions like
doWork(int x, int y, int z)
they refactored that into
doWork(Coordinate c)
and that's when Minecraft started eating RAM like some sort of delicious candy, because now each time you deal with a new Coordinate, it's one more object to garbage-collect. The old method may not have been particularly pretty, but plain ints are allocated on the stack and thus reduce GC pressure.
(BTW, can anyone confirm or deny that anecdote?)
- deleted 8y ago[deleted]
- dagw 8y agoI don't know about that particular anecdote, but the gist sounds very reasonable. I've seen/solved the exact same general thing in python on more than one occasion.
- MaxBarraclough 8y agoWas `Coordinate` a class or a struct? C# structs generally [0][1] don't force use of the garbage-collected heap. [0] https://blogs.msdn.microsoft.com/ericlippert/2010/09/30/the-truth-about-value-types/ https://blogs.msdn.microsoft.com/ericlippert/2010/09/30/the-... (ignore the usual comments telling the reader they are wrong for wondering about whether the garbage-collected heap is used) [1] https://jacksondunstan.com/articles/3453 https://jacksondunstan.com/articles/3453
- slavik81 8y agoMinecraft is a Java application.
- MaxBarraclough 8y agoDerp, of course! Mention of Microsoft threw me off :-P In the JVM, there are of course no structs, but I'd expect the escape analysis optimisations in the HotSpot JIT to reduce it down to avoiding any GC churn. If this isn't happening, I'm curious as to why.
- half-kh-hacker 8y agoYeah, that's true. After beta 1.8, coordinates started getting packaged as a class which MCP calls 'BlockPos'.