6 ms·
The author doesn't say you should use a language without GC, but minimize its effects. There are techniques to avoid GC churn by reducing allocations and the su
by icebraining 8y ago
The author doesn't say you should use a language without GC, but minimize its effects. There are techniques to avoid GC churn by reducing allocations and the subsequent cleanups.
- majewsky 8y agoI 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'.
- davedx 8y agoThis. My last contract was working on digital TV UI software that was build using nodejs, so we did a lot of work optimizing our code and architecture to reduce latencies and load times. I ended up going down the rabbit hole of how v8, libuv and node's GC work. It was a great learning experience. You really can influence your app's performance if you have the attitude and determination.
- phtrivier 8y agoOh I absolutely agree that it can be done, I just wish the article had went into more details about how that's done...