News for hackers. Stuff that matters.
Re:Why Discord is switching from Go to Rust by pkolaczk on Tuesday February 04, 2020 @05:17PM (#22241663)
A high number of short lived allocations is also a bad thing in a compacting GC environment, because every allocation gets you a reference to a memory region touched very long time ago and it is likely a cache miss. You would like to do an object pool to avoid this but then you run into a pitfall with long living objects, so there is really no good way out.
Re:Why Discord is switching from Go to Rust by mcguire on Tuesday February 04, 2020 @06:31PM (#22242313)
???

The allocation is going to be close to the last allocation, which was touched recently, no? The first allocation after a compaction wii be far from recent allocations, but close to the compacted objects?

Re:Why Discord is switching from Go to Rust by pkolaczk on Wednesday February 05, 2020 @01:46PM (#22249840)
Close to the last allocation doesn't matter. What matters is the memory returned to the application - and this is memory that has been touched long ago and unlikely in cache. If your new generation size is larger than L3 cache it will have to be fetched from main memory for sure every time you start the next 64 bytes. I believe a smart cpu will notice the pattern and will prefetch to reduce cache miss latency. But a high allocation rate will use a lot of memory bandwidth and would thrash the caches.

An extreme case of that problem happens when using GC in an app that gets swapped out. Performance drops to virtually zero then.