Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
July 29, 2015 How disruptive is the GC? | ||||
---|---|---|---|---|
| ||||
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? |
July 29, 2015 Re: How disruptive is the GC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Snape | 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.
|
July 29, 2015 Re: How disruptive is the GC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Snape | 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 |
July 30, 2015 Re: How disruptive is the GC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Namespace | 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).
|
August 01, 2015 Re: How disruptive is the GC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Snape | 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.
|
August 02, 2015 Re: How disruptive is the GC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Snape | 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: http://dlang.org/phobos/core_thread.html#.thread_detachThis 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. |
August 02, 2015 Re: How disruptive is the GC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marc Schütz | 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. |
Copyright © 1999-2021 by the D Language Foundation