Tuning Java or JS code to avoid allocations can sometimes be useful, but you aren’t likely to gain much if any *throughput* from it. The most you can expect is reducing the GC pause frequency. (This is different in languages like Go or Rust that have relatively slow allocation.)
-
-
Show this threadThanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
This Tweet is unavailable.
-
Someone should implement a language that heap-allocates all call frames (like SML/NJ does), allocates the nursery backwards, and stores the nursery high-water mark in RSP, just to blow people’s minds
- 2 more replies
-
-
-
doesn't even have to be that optimized, it's also a pointer bump in OCaml
-
Yeah, I mean “optimized” in the sense of “following best practices for GC”, not like micro-optimized.
End of conversation
New conversation -
-
-
The problem is the indirect cost. Generational hypothesis needs some time to play out. If you GC sooner because you allocated heavily, lots of objects that are actually very short lived may end up being copied to next generation because you didn't give the nursery enough time.
-
So for e.g. games with GC (like Unity) the rule of thumb that "allocations are expensive" is still true, it's just not expensive where the allocation happens. Expensive indirectly and in aggregate.
- 2 more replies
New conversation -
-
-
Eh who is claiming that the allocation is slow? I think more people are worried about the...garbage collecting part, and the required sand in the gears like read/write barriers.
-
Oh I see your second tweet explains the context much better :)
End of conversation
New conversation -
-
-
not super knowledgable about the subject, but I always thought stack allocation was better because of less cache-misses and that actual allocation time was always mostly irrelevant.
-
non-GC languages also need to pause when deallocating memory because it sometimes gets too fragmented, but you can control when that happens. So GC is not slower, just less deterministic.
- 2 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.