4 ms·
Or even better.. I've written 3D/Game Engines engines in languages with GC based runtimes that run at 1500fps with no GC pauses. How to do it? Easy... don't c
by socmag 10y ago
Or even better..
I've written 3D/Game Engines engines in languages with GC based runtimes that run at 1500fps with no GC pauses.
How to do it? Easy... don't create garbage! So yes, it is doable. PITA but doable
Certainly helps if you have a good generational GC.
That said, if you can force a compaction once a frame and it's pretty stable at a millisecond, I guess that's more than fine for a lot of stuff.
- nameless912 10y agoExactly this. In Java, it's definitely possible to almost completely avoid garbage, and the GC is tunable enough that you could consistently have the GC run once per frame, which then makes it just a normal part of the frame timing if you have a general idea of what is being created. Object pooling is magical, yo. I imagine in Golang, this would only get easier as the pauses are super short and I feel more control over the memory allocation (whether this is true or not is an open question).
- socmag 10y agoYes, definitely a lot of object pooling! :+1: Use POD's to store data ...and use "int's" instead of references. Those index into tables of the objects. These will be opaque to the GC so it doesn't have to follow any pointers.
- nameless912 10y agoPOD's?
- socmag 10y agoOops sorry.. Plain Old Data structures. Specifically I mean data structures that contain only basic types and no reference types or pointers. https://en.m.wikipedia.org/wiki/Passive_data_structure https://en.m.wikipedia.org/wiki/Passive_data_structure Another important trick is to use structures of arrays, rather than arrays of structures. Well that kind of depends on the use case, but you can get huge wins in memory access if you need to scan only one field. Same tradeoff as Row vs Column Databases.