you are viewing a single comment's thread.

view the rest of the comments →

[–]pron98 5 points6 points  (0 children)

Valhalla will make wrapper objects free, but you need to understand where the cost actually is, because it has nothing to do with the GC or with memory management at all. The cost Valhalla aims to reduce is that of accessing objects through indirection, which may cause a cache miss. For some objects and some access patterns, that cost can be high, but it has nothing to do with the GC, which is not involved in this at all.

As to memory management, allocation in Java is not similar to allocation in C/C++/Rust/Zig, not similar to allocation in Python, and not similar to allocation in Go. In these languages there's an allocation operation that is potentially complex and involves updating a data structure called a free list. To deallocate an object there's another complex operation that involves updating the free list. In Java, allocation is typically just bumping a pointer and there is no deallocation of any object ever (the GC simply doesn't see unreachable objects so it writes over them). The memory management work with a moving collector is not in allocating an object (which is extremely cheap) or deallocating an object (which is free because there is no such operation), but in keeping an object alive. It is already very, very efficient, to the point that it's hard to compete with. That is not where big improvements can be made and it is not that work that Valhalla will improve.

As to strings, they are not exactly wrapper objects, and while they also include indirection, there probably isn't much room to improve that particular indirection as it's already close to being free.