News for hackers. Stuff that matters.
Re:CPU Cache Essentials by phserr on Wednesday June 25, 2014 @05:10PM (#7946776)
What I meant was just how having a less direct control over memory (like you do with c/c++) affects (edit: in a practical way) the efficiency of cache usage. Having less control means being unable to pack things together as much as one would want, but I'm sure sophisticated GC algorithms (relocating/compacting/generational/incremental) directly or indirectly deal with that somehow. As I said, I'm inexperienced with GC and my understanding of them is probably a bit naive.
Re:CPU Cache Essentials by sliverstorm on Wednesday June 25, 2014 @06:21PM (#7947099)
From what I've read, the real worry with (for example) C++ is not whether you can control packing or memory ordering. The real worry is when you create data structures that are fundamentally cache-unfriendly. The compiler won't reachitect an object into other objects to make it more memory friendly.

Simple example from the slides on optimizing for the PlayStation 3; if your object is large and full of different data, you miss a lot and burn lots of cache space every time you access it because it is so large. If your object is small and just a collection of pointers, you burn little cache space when you load it, and data can be arranged more appropriately.

http://research.scee.net/files/presentations/gcapaustralia09...

Re:CPU Cache Essentials by voidlogic on Wednesday June 25, 2014 @11:08PM (#7947940)
Just to you are aware, you are presenting a false dichotomy. There are plenty of languages that are both garbage collected and give you quite a bit of control about memory layout (D, Go, Rust, etc).

For example, in Go if I wanted have a slice of Foobar ([]Foobar) but wanted to have them allocated close to one another I could write:

  const neededFoobars = 100
  backingSlice := make([]Foobar, neededFoobars)
  seqfoobarPtrs := make([]*Foobar, neededFoobars)
  for i := 0; i < neededFoobars; i++ {
      seqfoobarPtrs[i] = &backingSlice[i]
  }
Re:CPU Cache Essentials by dbaupp on Thursday June 26, 2014 @01:48AM (#7948281)
(FWIW, Rust is not garbage collected.)
Re:CPU Cache Essentials by voidlogic on Thursday June 26, 2014 @11:27AM (#7950136)
Rust has optional garbage collection
Re:CPU Cache Essentials by FreeFull on Thursday June 26, 2014 @12:16PM (#7950338)
There is a library type that does reference counting. It's not built into the language, beyond happening to be in the standard libraries.
Re:CPU Cache Essentials by dbaupp on Friday June 27, 2014 @06:39PM (#7956592)
It doesn't. There is a type called Gc that may be garbage collected in future, but at the moment it is just a bad reference counted pointer (the Rc type is better if you want reference counting). And it's not even guaranteed that a GC will ever be implemented, Rust provides other abstractions so GC would be rarely used even if it was implemented.