News for hackers. Stuff that matters.
Re:Reclaiming C++ Data Structures with Cycles by daemin on Thursday October 13, 2016 @11:04AM (#12701182)
Yes, but in this case we know when the allocations will occur, and when they will be freed. If using a GC we know when they will occur, but do not know when they will be freed. Which means that at some indeterminate point in the future there will be a large temporary slowdown due to processing the GC.

This is one of the bigger reasons people use C++ and even techniques within it to explicitly collect such items at a known point in time. (Techniques such as marking items as dead in an array but still keeping them in there until the end of frame, etc)

Re:Reclaiming C++ Data Structures with Cycles by titzer on Thursday October 13, 2016 @12:41PM (#12702042)
> If using a GC we know when they will occur, but do not know when they will be freed. Which means that at some indeterminate point in the future there will be a large temporary slowdown due to processing the GC.

This just isn't true anymore. Incremental collectors can achieve pause times in the single-digit millisecond range, and concurrent collectors can achieve pause times in the single-digit to tens of microseconds range, even for super-high-allocation rate programs. There are even real-time collectors suitable for audio and other hard real-time applications.

Azul GC (a high performance concurrent compacting collector): https://www.azul.com/products/zing/pgc/

Metronome (a real-time GC with guaranteed maximum pause times): http://researcher.watson.ibm.com/researcher/view_group_subpa...

GC scheduling in V8 (hides GC pause times between frames, reducing animation jank): http://queue.acm.org/detail.cfm?id=2977741

The Go GC ships now with a very low-latency GC: https://blog.golang.org/go15gc

Re:Reclaiming C++ Data Structures with Cycles by paulsutter on Thursday October 13, 2016 @05:25PM (#12704169)
> This just isn't true anymore. Incremental collectors can achieve pause times in the single-digit millisecond range

Single digit milliseconds is millions of instructions, which /is/ a large slowdown in some applications.

Re:Reclaiming C++ Data Structures with Cycles by titzer on Friday October 14, 2016 @02:40AM (#12706465)
How much do you think a page fault costs?
Re:Reclaiming C++ Data Structures with Cycles by paulsutter on Friday October 14, 2016 @03:29AM (#12706598)
Page faults cost zero. On locked pages.
Re:Reclaiming C++ Data Structures with Cycles by daemin on Friday October 14, 2016 @05:47AM (#12707028)
A millisecond is a huge amount of time, and in that time we can do so many more things more useful to the application than just collecting its trash.
Re:Reclaiming C++ Data Structures with Cycles by titzer on Friday October 14, 2016 @02:41AM (#12706469)
Again downvotes. It'd be nice if people actually replied instead of downvoting.
Re:Reclaiming C++ Data Structures with Cycles by branchless on Thursday October 13, 2016 @11:08AM (#12701210)
This is the advantage of C++ for me. Deterministic behaviour.
Re:Reclaiming C++ Data Structures with Cycles by chrisseaton on Thursday October 13, 2016 @05:04PM (#12704012)
But is it deterministic? Will the allocator always have a deterministic amount of work to do to find enough free space for your string characters? I'm not sure that's the case.
Re:Reclaiming C++ Data Structures with Cycles by monocasa on Thursday October 13, 2016 @05:27PM (#12704187)
Which allocator? For those who care, they replace the allocator.
Re:Reclaiming C++ Data Structures with Cycles by junke on Thursday October 13, 2016 @12:26PM (#12701896)
You can deactivate GC momentarily and reclaim memory when you want (end of frame, every ten frames, ...). Most of the time you can manage to write your code to minimize allocation, or make sure memory is allocated on the stack. Depending on your parameters and a little bit of profiling, you can manage to have a stable usage of memory over time and a bounded GC time.