www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How disruptive is the GC?

reply "Snape" <sdadas sssss.com> writes:
I'm in the early stages of building a little game with OpenGL (in 
D) and I just want to know the facts about the GC before I decide 
to either use it or work around it. Lots of people have said lots 
of things about it, but some of that information is old, so as of 
today, what effect does the GC have on the smooth operation of a 
real-time application? Is it pretty noticeable with any use of 
the GC or only if you're deallocating large chunks at a time?
Jul 29 2015
next sibling parent Rikki Cattermole <alphaglosined gmail.com> writes:
On 29/07/2015 9:25 p.m., Snape wrote:
 I'm in the early stages of building a little game with OpenGL (in D) and
 I just want to know the facts about the GC before I decide to either use
 it or work around it. Lots of people have said lots of things about it,
 but some of that information is old, so as of today, what effect does
 the GC have on the smooth operation of a real-time application? Is it
 pretty noticeable with any use of the GC or only if you're deallocating
 large chunks at a time?
Some tips: - Avoid allocations if possible - Use buffers/preallocated memory if possible - Disable the GC (collection only) - Use allocators instead of e.g. new - -vgc is awesome If you are using GC to allocate (not really a good idea), run collect when you have some spare cycles. Can't really say much about the current GC implementation. But what I do know is for real time apps GC is not a good tool for memory management.
Jul 29 2015
prev sibling next sibling parent reply "Namespace" <rswhite4 gmail.com> writes:
On Wednesday, 29 July 2015 at 09:25:50 UTC, Snape wrote:
 I'm in the early stages of building a little game with OpenGL 
 (in D) and I just want to know the facts about the GC before I 
 decide to either use it or work around it. Lots of people have 
 said lots of things about it, but some of that information is 
 old, so as of today, what effect does the GC have on the smooth 
 operation of a real-time application? Is it pretty noticeable 
 with any use of the GC or only if you're deallocating large 
 chunks at a time?
http://3d.benjamin-thaut.de/?p=20
Jul 29 2015
parent "Kapps" <opantm2+spam gmail.com> writes:
On Wednesday, 29 July 2015 at 17:09:52 UTC, Namespace wrote:
 On Wednesday, 29 July 2015 at 09:25:50 UTC, Snape wrote:
 I'm in the early stages of building a little game with OpenGL 
 (in D) and I just want to know the facts about the GC before I 
 decide to either use it or work around it. Lots of people have 
 said lots of things about it, but some of that information is 
 old, so as of today, what effect does the GC have on the 
 smooth operation of a real-time application? Is it pretty 
 noticeable with any use of the GC or only if you're 
 deallocating large chunks at a time?
http://3d.benjamin-thaut.de/?p=20
Note that this was 3 years ago, so there have been GC improvements since then. I'm not sure what the results would be like today (or what the code is like in terms of needless allocations). That being said, you probably want to avoid the GC as much as possible for games. Luckily we have tools like -vgc to help with that now (and nogc, but I still consider this mostly unusable thanks largely to exceptions).
Jul 29 2015
prev sibling next sibling parent "ponce" <contact gam3sfrommars.fr> writes:
On Wednesday, 29 July 2015 at 09:25:50 UTC, Snape wrote:
 I'm in the early stages of building a little game with OpenGL 
 (in D) and I just want to know the facts about the GC before I 
 decide to either use it or work around it. Lots of people have 
 said lots of things about it, but some of that information is 
 old, so as of today, what effect does the GC have on the smooth 
 operation of a real-time application? Is it pretty noticeable 
 with any use of the GC or only if you're deallocating large 
 chunks at a time?
The GC is noticeable and you will probably have to minimize the heap size. Fortunately the use of -vgc and nogc helps a lot to mitigate the pauses.
Aug 01 2015
prev sibling parent reply "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> writes:
On Wednesday, 29 July 2015 at 09:25:50 UTC, Snape wrote:
 I'm in the early stages of building a little game with OpenGL 
 (in D) and I just want to know the facts about the GC before I 
 decide to either use it or work around it. Lots of people have 
 said lots of things about it, but some of that information is 
 old, so as of today, what effect does the GC have on the smooth 
 operation of a real-time application? Is it pretty noticeable 
 with any use of the GC or only if you're deallocating large 
 chunks at a time?
I'd like to add that you can tell the runtime (and therefore the GC) to ignore a thread: This allows you to implement real-time tasks in that thread, and it will never be interrupted by the GC. You can still use the GC in other threads. Of course, you need to make sure not to call into the GC from the detached thread (easy by using nogc), and to keep at least one reference to GC data used in the detached thread in a normal thread.
Aug 02 2015
parent "Temtaime" <temtaime gmail.com> writes:
I'm writing a game engine in D. Try to minimize allocations and 
that's will be OK.
I'm using delegates and all the phobos stuff. I allocate only in 
few places at every frame.
So i can reach 1K fps on a complicated scene.

GC is not a problem. DMD optimizes so ugly that all the math is 
very, very slow.
DMD gives me about 200 fps, when with LDC i can reach 1k.
Aug 02 2015