On Tuesday, 13 May 2014 at 06:12:46 UTC, Rainer Schuetze wrote:
On 13.05.2014 00:15, Martin Nowak wrote:
There is a problem with this scheme, copy-on-write is extremely
expensive when a mutation happens. That's one page fault
(context
switch) + copying a whole page + mapping the new page.
I agree that this might be critical, but it is a one time cost
per page. It seems unrealistic to do this with user mode
exceptions, but the OS should have this optimized pretty well.
As I pointed out this won't help dynamic games that easily can
touch 50000 pages per frame if you use a single global allocator.
2000 cycles * 50K = 100K = frame drop. What's worse, if you are
low on memory you will start to swap to disk (or compress pages).
So that means you have to optimize for collections, use dedicated
allocators that keep dynamic data on the same pages etc...
Basically you get the disadvantage of manual memory management
and in the worst case the memory requirements of a copying GC
without the benefits...