6 ms·
There's so many good quotes in this article. Two of my favorites: "It isn't that the generational hypothesis isn't true for Go, it's just that the young object
by steveklabnik 8y ago
There's so many good quotes in this article. Two of my favorites:
"It isn't that the generational hypothesis isn't true for Go, it's just that the young objects live and die young on the stack."
"... we are led to the conclusion that memory, or at least chip capacity, will follow Moore's law longer than CPUs"
Kudos to the Go team!
- pjmlp 8y ago"No more C, no long tail of bugs due to C coders not understanding GC but having a cool idea about how to copy strings."
- w8rbt 8y agoI've seen more home made string implementations in C than I can remember. Most all of them were horrible. Say what you like about C++, but it certainly fixed that mess. And I love Go... I think it's the future.
- deleted 8y ago[deleted]
- pjmlp 8y ago> Say what you like about C++, but it certainly fixed that mess. Already in the MS-DOS days, even if string class back then was compiler framework specific, and part of ritual of passage as C++ developer.
- munificent 8y agoI've seen more home-made string implementations in C++ than C. :-/
- pjmlp 8y agoI bet all of them derive either from the days before std::string, which only started to be commonly supported after 2000, as compilers were catching up with C++98. The typical rite of passage that every C++ developer needs to write their own string and vector classes as part of learning C before C++, instead of properly C++ as we can do nowadays. Finally those shops that don't allow to use proper C++ on their code, rather C with Classes.
- paulddraper 8y agoAh, good ol QString
- dullgiulio 8y agoIndeed, the quote about the generational hypothesis is particularly important since this comes up at every Go GC discussion, especially when someone brings up the "more advanced" GCs in Java. The generational hypothesis is not about the heap, it's about all allocations.
- ebikelaw 8y agoThe second statement is interesting, because it contradicts the thinking within Google (platforms and capacity management) that in the long run we're all deeply screwed on the DRAM front, whereas CPU performance will probably not hit a wall any time soon.
- yencabulator 8y agoThat might be a question of latency vs bandwidth. Often RAM is used for random-access workloads (duh), so latency matters. The GC is very much a sequential scan. The blog post talks about that, briefly.
- ernst_klim 8y agoWhat? Are Go interfaces and strings stack allocated? If not, this assertion looks dubious to me.
- steveklabnik 8y agoLet me say that I am not super familiar with the Go source, and so this may be wrong. Please correct me if this is true! My understanding is, the string itself is on the stack, but the data is on the heap https://github.com/golang/go/blob/2f2e8f9c81d899d8eefb1f2f98ce5c90976c4f61/src/runtime/string.go#L217-L220 https://github.com/golang/go/blob/2f2e8f9c81d899d8eefb1f2f98... Likewise, the "double pointer" of an interface is on the stack, but points to the heap: https://research.swtch.com/interfaces https://research.swtch.com/interfaces So, from a lifetime perspective, it's still pretty stack-like. If you make a string, and you don't refer to it from outside the function, it's gonna get noticed by escape analysis and be like anything else on the stack.
- ernst_klim 8y ago>the string itself is on the stack, but the data is on the heap So both are regular heap allocated values? So the majority of data is still stack (edit: heap) allocated (safe ints, floats and some simple structs, I suppose), so I fail to see how ``young objects live and die young on the stack''. It is true that some GCed languages does not have stack allocation at all, but many of them (java, haskell) have very powerful inlining capabilities to compensate it. I still don't understand why I don't need generations for allocating to-die-soon strings in a more efficient ways.
- pcwalton 8y agoYou are correct. Properly-implemented copying generational GCs are the only things that work to optimize allocation of strings, arrays, and objects judged to be escaping.
- steveklabnik 8y ago> So the majority of data is still stack (edit: heap) It doesn't matter that the string's data lives somewhere else. It matters where what owns it lives. The string itself, that is, the pointer and length, both live on the stack, and so, it ends up working like a stack allocated value. > I still don't understand why I don't need generations for allocating to-die-soon strings in a more efficient ways. Because the string itself isn't on the heap, and therefore, a generation wouldn't help it.