This is one of my favourite anecodtes to tell peers and colleagues because it's important when understanding buisness case/needs against programming. We all want to make perfect software, but it isn't always neccessary.
As I heard the tale, on the Standard Missile, they don't recirculate the hydraulic fluid, they just spit out as the missile flies. It's a wonderful engineering solution.
Yeah if you have for example a http request, you can just collect garbage you create during that request in a single region, then throw it away when the request has been handled. This is quite standard.
I wish the author section provided what production garbage collectors the authors worked on. There's plenty of nonintuitive things you can learn in the real world, so a book including those would be both interesting and useful.
This is a truly remarkable book, and a must read for any engineer who depends on a gc . And if you don’t need a gc, the book starts by talking about allocators, which are actually very important too !
I see that there is a section (relatively short) on real time GC. But for anyone who has read the Handbook, how much emphasis is placed on GC in constrained environments. I have fought the urge to implement a 3D, modern AA game with GC just to prove it is viable outside all but the most resource poor platforms or the most AAAAA, cutting edge, every cycle counted, hyper optimized game. But I am transitioning to a slightly less focused area of responsibility at work and may have some free time to prototype and this may be how I spend my winter and spring free time.
I think you would be hard-pressed to find a modern AA game that does not already use a GC. The major game engines Unreal and Unity are garbage collected - although they use manual memory management for some of their internals, the exposed API surface (including the C++ API) is designed with garbage collection in mind.
Notably, the popular-with-hobbyists Godot Engine does not use a garbage collector. It uses reference counting with some objects, but does not provide cycle detection, thus requires all objects to be laid out in a tree structure (which the engine is built around).
US navy has weapons targeting systems on some battleships implemented in Java with realtime GC, equally France has missile tracking systems, also implemented in Java with realtime GC, courtesy of PTC and Aonix.
There's a bunch of caveats to that story. At one point (in one patch I recall) they got tired of passing around 3 floats separately for x, y, and z all the time, so they did what any reasonable programmer would do and created a "coordinate" structure.
This created one of the worst performing partches of the game ever, and they had to back all the way out. They ended up just passing the separate floats around again.
My takeaway is that GC doesn't have to be slow, it just imposes a bunch of new constraints on what can be fast.
The problem there is probably that Java cannot pass objects by value [1]. That incurs an additional layer of indirection when accessing the individual members of the struct, tanking performance.
That's not a necessity, though - you can use a GC in languages that allow you to control whether structs get allocated on the heap or on the stack, and then you don't have this issue. For example, in Go, structs can be allocated on the stack and passed by value, or they can be allocated on the heap and passed by reference, and this is under the control of the application programmer [2].
[1]: Actually, according to the Java spec, Java does not have pass-by-reference, and objects are always passed by value. However, that's just strange nomenclature - in Java parlance, "object" names the reference, not the actual range of memory on the heap.
[2]: The language spec does not guarantee this, so this is technically implementation-defined behavior. But then, there's really only one implementation of the Go compiler and runtime.
Not much. The book mostly covers theory and not platform-specific details. The explanations on various real-time gc algorithms are very thorough though.
I had Hosking as a professor. Iirc, it was an okay experience. Compilers course I believe.
When the handbook came out, I bought it because "hey, I know that guy". Ultimately, I don't think it's necessary, but having a more in depth knowledge of garbage collection and the problems in the space occasionally comes in handy.
For example, what implication do finalizers have on garbage collection design? Reading about that was kind of an eye opener.
My favorite story about garbage collection: https://devblogs.microsoft.com/oldnewthing/20180228-00/?p=98...
This is one of my favourite anecodtes to tell peers and colleagues because it's important when understanding buisness case/needs against programming. We all want to make perfect software, but it isn't always neccessary.
It’s pretty standard in many places I think - the point here is not the null gc but rather exact memory requirements being proved statically.
They do that in other places.
As I heard the tale, on the Standard Missile, they don't recirculate the hydraulic fluid, they just spit out as the missile flies. It's a wonderful engineering solution.
And on the Falcon 9, the hydrocarbon fuel is used as hydraulic fluid, then just dumped back into the fuel tank.
And the SR-71 uses its fuel as coolant.
"There was a lot we couldn't do, but we were the fastest kids on the block..."
I would call that a region-based memory allocator... Only that it has a single region, ever.
Yeah if you have for example a http request, you can just collect garbage you create during that request in a single region, then throw it away when the request has been handled. This is quite standard.
Well, the garbage is collected when the missile hits the target region.
The garbage is spread out over the target region.
Or it's a generational garbage collector with the generation management and collection functionality omitted.
now that is what i call the ultimate in garbage collection technology
I think the missile impact creates a lot more garbage spread over a wider area.
I wish the author section provided what production garbage collectors the authors worked on. There's plenty of nonintuitive things you can learn in the real world, so a book including those would be both interesting and useful.
This is a truly remarkable book, and a must read for any engineer who depends on a gc . And if you don’t need a gc, the book starts by talking about allocators, which are actually very important too !
Great book. Previous discussion: https://news.ycombinator.com/item?id=35492307
(387 points, 166 comments)
I see that there is a section (relatively short) on real time GC. But for anyone who has read the Handbook, how much emphasis is placed on GC in constrained environments. I have fought the urge to implement a 3D, modern AA game with GC just to prove it is viable outside all but the most resource poor platforms or the most AAAAA, cutting edge, every cycle counted, hyper optimized game. But I am transitioning to a slightly less focused area of responsibility at work and may have some free time to prototype and this may be how I spend my winter and spring free time.
I think you would be hard-pressed to find a modern AA game that does not already use a GC. The major game engines Unreal and Unity are garbage collected - although they use manual memory management for some of their internals, the exposed API surface (including the C++ API) is designed with garbage collection in mind.
Notably, the popular-with-hobbyists Godot Engine does not use a garbage collector. It uses reference counting with some objects, but does not provide cycle detection, thus requires all objects to be laid out in a tree structure (which the engine is built around).
US navy has weapons targeting systems on some battleships implemented in Java with realtime GC, equally France has missile tracking systems, also implemented in Java with realtime GC, courtesy of PTC and Aonix.
https://www.militaryaerospace.com/defense-executive/article/...
https://www.lockheedmartin.com/en-us/products/aegis-combat-s...
https://vita.militaryembedded.com/1670-aonix-uss-bunker-hill...
Not all GC are born alike, and in real life there isn't "insert credit to continue".
Minecraft is the best selling game of all time, uses GC, and is an indie game.
There's a bunch of caveats to that story. At one point (in one patch I recall) they got tired of passing around 3 floats separately for x, y, and z all the time, so they did what any reasonable programmer would do and created a "coordinate" structure.
This created one of the worst performing partches of the game ever, and they had to back all the way out. They ended up just passing the separate floats around again.
My takeaway is that GC doesn't have to be slow, it just imposes a bunch of new constraints on what can be fast.
The problem there is probably that Java cannot pass objects by value [1]. That incurs an additional layer of indirection when accessing the individual members of the struct, tanking performance.
That's not a necessity, though - you can use a GC in languages that allow you to control whether structs get allocated on the heap or on the stack, and then you don't have this issue. For example, in Go, structs can be allocated on the stack and passed by value, or they can be allocated on the heap and passed by reference, and this is under the control of the application programmer [2].
[1]: Actually, according to the Java spec, Java does not have pass-by-reference, and objects are always passed by value. However, that's just strange nomenclature - in Java parlance, "object" names the reference, not the actual range of memory on the heap.
[2]: The language spec does not guarantee this, so this is technically implementation-defined behavior. But then, there's really only one implementation of the Go compiler and runtime.
Value types would solve that issue flawlessly.
Yeah but it’s a game category where is that’s viable
Unreal Engine has a GC for its internal object graph, so GC is already in use in a ton of games.
Not much. The book mostly covers theory and not platform-specific details. The explanations on various real-time gc algorithms are very thorough though.
Wouldn't all the popular games based on Unity and written in C# count?
I have this, it is very well written and thorough. Highly recommend!
I had Hosking as a professor. Iirc, it was an okay experience. Compilers course I believe.
When the handbook came out, I bought it because "hey, I know that guy". Ultimately, I don't think it's necessary, but having a more in depth knowledge of garbage collection and the problems in the space occasionally comes in handy.
For example, what implication do finalizers have on garbage collection design? Reading about that was kind of an eye opener.