3 ms·
Seriously, with sub-ms pause times of ZGC you could run a GC every frame and have tons of time to space for actual processing.
by admax88qqq 5y ago
Seriously, with sub-ms pause times of ZGC you could run a GC every frame and have tons of time to space for actual processing.
- dandotway 5y agoIt sounds very nice but if more than half an indie game's revenue comes from Nintendo Switch then you need a low friction way to get your .java files running there. You also need a proven audio mixer stack so you can load background_music.mp3 and play bang.wav and boom.wav without any popping or leaks. Right now Java seems sort of iffy on consoles, as in, you could maybe spend a ton of time and/or money to get an effort like GraalVM production-grade working there, but no one has bothered to do it yet. It seems to be much lower friction to just use C#/MonoGame, or SDL2 with your scripting language of choice that compiles with a C/C++ compiler, or a proven game engine.
- titzer 5y agoA pause does not correspond to a full GC, of course. The work of GC is split into a lot of concurrent work and a lot of really tiny pauses on each application thread. The entire GC cycle might be split over hundreds or thousands of tiny pauses and take many seconds--there's just no particularly big pause. During the GC cycle the application is still running and allocating, and there is enough slack space that it doesn't run out of memory before the GC cycle finishes and transparently adds freed memory back into the usable pools. It would be great if the whole cycle were that fast! But alas, there simply isn't enough memory bandwidth to GC 128GB of memory in 0.1 millisecond :)
- admax88qqq 5y agoThat's fair, although you're not free()'ing 128GB in 0.1ms either :) The amortized cost of GC is more efficient that malloc/free, but it's traditionally not good for latency sensitive systems due to long pause times causing jank/dropped frames. Now that GC algorithms like ZGC have advanced to give sub ms pause times, you no longer have that worry. Technically we didn't need ZGC for this to begin with. IBM launched metronome a while back for real-time systems, but it was never as widely available as ZGC. In a game you should keep allocations during gameplay to a minimum anyways, malloc() is not O(1) is has variable runtime based upon the current layout of free memory. Additionally, long running malloc/free based applications have unfixable memory leaks due to memory fragmentation. In my opinion there's very few cases where you should be dynamically allocating memory, and not using a garbage collector.
- admax88qqq 5y ago> That's fair, although you're not free()'ing 128GB in 0.1ms either :) Well I guess that's not technically true, free() could very well be a quick operation if you have a single 128GB object.