▲ | masklinn 8 months ago | ||||||||||||||||||||||
Yes, but that’s the point: objects which don’t escape are pretty much all young objects. So by this process the stack captures a significant fraction of the young generation, that young generation never reaches the heap and this is never under consideration by the GC. Essentially the stack is a form of younggen. It is not as complete (as there are things which must be heap allocated) but because it is, it reduces the benefits of a generational GC… without having much impact on its costs and complexity. Depending on work load, that competition can be sufficient to make a generational GC net negative. | |||||||||||||||||||||||
▲ | pron 8 months ago | parent | next [-] | ||||||||||||||||||||||
1. How significant that portion is may be lower than you think. 2. Stack allocation adds complexity that actually can adversely affect performance. The main problem is that for stack objects to behave more like heap objects, you need to be able to reference them. References into the stack make user-mode threads less flexible. For example, Go takes a significant hit for Go-native interop in goroutines, whereas Java doesn't pay that cost. 3. Why do you, as a user, care if the GC is more complex? | |||||||||||||||||||||||
| |||||||||||||||||||||||
▲ | DarkNova6 8 months ago | parent | prev | next [-] | ||||||||||||||||||||||
Thanks for the answer. But is this actual behaviour for the GCs of the JDK? I was certain that at the very least Hotspot makes use of stack allocation as much as possible. But perhaps the JDK GCs don't care so much about the stack because that is already dealt by the JVM a step prior? In any case, there will likely still be young objects allocated in the heap and this new algorithm might prove useful. But you can tell I am far from an expert here. | |||||||||||||||||||||||
| |||||||||||||||||||||||
▲ | pfdietz 8 months ago | parent | prev [-] | ||||||||||||||||||||||
I wonder if architectural support could be added to reduce the cost of recording modification information. |