Live data from Hacker News

For Better Computing, Liberate CPUs from Garbage Collection

spectrum.ieee.org

451–460 of 460 posts

Re: For Better Computing, Liberate CPUs from Garbage Collection

#451

Earlier quoted context omitted.

That's what smart pointers/ref counting is for

C++ is the flagship language for smart pointers and UAF memory corruption flaws are endemic to it.

Doesn't seem related though?

Unless you want to pick on the specific implementation?

Re: For Better Computing, Liberate CPUs from Garbage Collection

#452

Earlier quoted context omitted.

Erlang style immutable reference counted shared memory is not at all state of the art. Persistent data structures are common and effective. I have implemented several myself, to store and update trees that don't fit in main memory. If you're updating one byte of your physicist's (say) 1 petabyte dataset, it requires ten memory allocations (log[branch factor] of the size of the dataset). If you're updating the whole t…

Are there high-performance matrix multiplication libraries, e.g. for fluid-dynamics simulations, that are implemented using persistent data structures?

[deleted]

Re: For Better Computing, Liberate CPUs from Garbage Collection

#453

Earlier quoted context omitted.

Erlang style immutable reference counted shared memory is not at all state of the art. Persistent data structures are common and effective. I have implemented several myself, to store and update trees that don't fit in main memory. If you're updating one byte of your physicist's (say) 1 petabyte dataset, it requires ten memory allocations (log[branch factor] of the size of the dataset). If you're updating the whole t…

Are there high-performance matrix multiplication libraries, e.g. for fluid-dynamics simulations, that are implemented using persistent data structures?

Are there any where multiple threads are mutating overlapping sections of memory? How exactly do you think a GPU matrix multiply violates my initial assertion?

Re: For Better Computing, Liberate CPUs from Garbage Collection

#454
post #210
post #113

Earlier quoted context omitted.

> But all of these are much cheaper than developer labour and reputation damage caused by leaky/crashy software. And that's why so much effort has gone into making it fast and low latency, but it was a false dichotomy: We can have memory safety without garbage collection. - Automatic reference counting: Most people know about Objective-C's efforts in this space, but it's admittedly less automatic than programmers wou…

This comment is just bad and misinformed all over. (1) Automatic Reference Counting doesn't work; its equivalent in interpreted languages is, well, reference counting , which can be optimized quite a lot (though has some issues with multithreading), but cannot collect cycles. (2) therefore, if you want reference counting, you have to either also have GC (for cycles), or program carefully to avoid creating cycles (whi…

Please don't call names in arguments here. Your first sentence is clearly against the site guidelines, and was quite unnecessary.

https://news.ycombinator.com/newsguidelines.html

Re: For Better Computing, Liberate CPUs from Garbage Collection

#455
post #454
post #210

Earlier quoted context omitted.

This comment is just bad and misinformed all over. (1) Automatic Reference Counting doesn't work; its equivalent in interpreted languages is, well, reference counting , which can be optimized quite a lot (though has some issues with multithreading), but cannot collect cycles. (2) therefore, if you want reference counting, you have to either also have GC (for cycles), or program carefully to avoid creating cycles (whi…

Please don't call names in arguments here. Your first sentence is clearly against the site guidelines, and was quite unnecessary. https://news.ycombinator.com/newsguidelines.html

Sorry. I get emotional about programming languages...

Re: For Better Computing, Liberate CPUs from Garbage Collection

#456
post #210
post #113

Earlier quoted context omitted.

> But all of these are much cheaper than developer labour and reputation damage caused by leaky/crashy software. And that's why so much effort has gone into making it fast and low latency, but it was a false dichotomy: We can have memory safety without garbage collection. - Automatic reference counting: Most people know about Objective-C's efforts in this space, but it's admittedly less automatic than programmers wou…

This comment is just bad and misinformed all over. (1) Automatic Reference Counting doesn't work; its equivalent in interpreted languages is, well, reference counting , which can be optimized quite a lot (though has some issues with multithreading), but cannot collect cycles. (2) therefore, if you want reference counting, you have to either also have GC (for cycles), or program carefully to avoid creating cycles (whi…

(1/2): It most certainly does work: q/kdb is an interpreted language and doesn't have cycles. Being an array language, nesting is uncommon, so chasing pointers isn't an issue either.

(3): I didn't say otherwise Python doesn't also do reference counting. Python however does have a bytecode and a GC, and perl5 does not and executes the AST directly. And yes perl5 is faster for many problems[†]. I think it's quite common that people believe that GC and bytecode are a win, and this is a simple and accessible example where it is not true.

(4): More significant than what? q/kdb is implemented in this style, and it's a huge advantage (reducing bugs) having your library handle allocation/deallocation over having the caller do these things so I tend to do it as well. What exactly are you comparing it to? The mental load of figuring out what's causing pauses is quite high since it requires considering the entire program, but linear programming is very easy and it obviates a lot of need for other kinds of memory management techniques.

(5): Good enough for what? Why is mixing static analysis with runtime analysis "cheating"? What would be "fair" in your mind?

[†]: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re: For Better Computing, Liberate CPUs from Garbage Collection

#457
post #455
post #454

Earlier quoted context omitted.

Please don't call names in arguments here. Your first sentence is clearly against the site guidelines, and was quite unnecessary. https://news.ycombinator.com/newsguidelines.html

Sorry. I get emotional about programming languages...

Me too, as do many others.

Re: For Better Computing, Liberate CPUs from Garbage Collection

#458

Earlier quoted context omitted.

A Hummer isn’t any more O(n) than a Prius in terms of fuel used per n miles but that constant will still kill you. In practice, no one has ever demonstrated a garbage collected language that was more efficient than Rust/C/C++ other than in very specific cases. https://thenewstack.io/which-programming-languages-use-the-l...

The programming language benchmarks game is not great for finding idiomatic code, since it tends to be highly hand-tuned code. Dynamic allocation is slow, so both the C and non-C code will avoid it in the benchmarks game (the problems are usually sufficiently fixed-size that it will boil down to a single malloc() at the beginning, which is idiomatic in a lot of embedded C, but not for non-embedded C). Highly dynamic…

>but because the GC encourages (fails to discourage) a lot of allocations.

Yeah, but allocations in OCaml and Haskell are super cheap, nearly as cheap as on stack. Typical OCaml small allocation is:

  * add the number of words you wanna allocate to the heap pointer (%r15 on amd64)

  * check if it surpassed the limit

    + if it's fine — just write your data in -8(%r15)

    + if there is no space left — run GC

Re: For Better Computing, Liberate CPUs from Garbage Collection

#459
post #182
post #175

Earlier quoted context omitted.

> I think that garbage collection has proven to be the best idea in programming languages in the past decades, and probably the only one that has made an impact at all. Depends on how you set your thresholds. Paying more attention to side-effects / purity / const has been pretty useful, too. And so have mainstream languages adopting first class functions. And making it easy to compose data structures. (Compare eg how…

> Paying more attention to side-effects / purity / const has been pretty useful, too... I don't know. Studies haven't been able to find any big effects, and the industry isn't seeing them, either. You may like those things, but unlike GCs, it doesn't seem like they've made a real impact.

Interesting. Do you have links to these studies? Thanks!

Re: For Better Computing, Liberate CPUs from Garbage Collection

#460

Earlier quoted context omitted.

ARC optimizations do let it retain/release less often. For example, instead of a callee adding the return value to an autorelease pool then having the caller immediately retain the returned value, the autorelease+retain pair can be elided entirely.

> For example, instead of a callee adding the return value to an autorelease pool then having the caller immediately retain the returned value, the autorelease+retain pair can be elided entirely. Are you just referring to standard RVO? If you return a std::shared_ptr in C++ today you won't get the equivalent of retain+release, either, RVO avoids that.

Did you even take a look at the doc I posted?

> For example, if the user puts logging statements in retain, they should not be surprised if those statements are executed more or less often depending on optimization settings

> In general, ARC does not perform retain or release operations when simply using a retainable object pointer as an operand within an expression

> However, C and C++ already call this undefined behavior because the evaluations are unsequenced, and ARC simply exploits that here to avoid needing to retain arguments across a large number of calls.

> ARC performs no extra mandatory work on the caller side, although it may elect to do something to shorten the lifetime of the returned value.

Post reply on HN