digitalmars.D.learn - Garbage Collectors
- IchorDev (8/8) Jul 19 2023 So, D’s default garbage collector is the one named “conservative”
- Sergey (8/16) Jul 19 2023 Forking GC was introduced some time ago. But I don't think it is
- Richard (Rikki) Andrew Cattermole (7/13) Jul 19 2023 It is a modification of the conservative GC. Rather than a unique GC
- Richard (Rikki) Andrew Cattermole (6/6) Jul 19 2023 Its not as simple as porting to the API unfortunately.
- IchorDev (4/11) Jul 19 2023 I'm mostly a frontend person, but is what would need doing there?
- Richard (Rikki) Andrew Cattermole (5/18) Jul 19 2023 Not really, last time I tried, I didn't document what was hidden.
- IchorDev (5/9) Jul 19 2023 That sounds pretty easy, but I don't really see how would that be
- Richard (Rikki) Andrew Cattermole (10/20) Jul 19 2023 druntime supports registering of GC's not compiled with druntime.
- IchorDev (9/17) Jul 19 2023 Oh right, so it's more of a matter of making GC-related code part
- Johan (8/10) Jul 19 2023 Side remark: LDC ships with the ldc-build-runtime tool which
- Steven Schveighoffer (3/13) Jul 22 2023 This is very cool to know, I wasn't aware!
- Steven Schveighoffer (10/18) Jul 19 2023 To answer the question about ProtoGC, it is a stub GC which will create
So, D’s default garbage collector is the one named “conservative” in DRuntime… I see there’s also “manual” which doesn’t actually function as a GC, which is interesting. Nothing says what ProtoGC is… so I guess it’s useless. Has anyone ever published any custom GCs? A search through the dub package registry yielded nothing. How hard would it be to port (for instance) a Java GC to D’s interface?
Jul 19 2023
On Wednesday, 19 July 2023 at 07:24:06 UTC, IchorDev wrote:So, D’s default garbage collector is the one named “conservative” in DRuntime… I see there’s also “manual” which doesn’t actually function as a GC, which is interesting. Nothing says what ProtoGC is… so I guess it’s useless. Has anyone ever published any custom GCs? A search through the dub package registry yielded nothing. How hard would it be to port (for instance) a Java GC to D’s interface?Forking GC was introduced some time ago. But I don't think it is quite different from regular (https://forum.dlang.org/post/tf8mbo$1jvp$1 digitalmars.com) There are some posts about it GCs, but I don't think anything was released. https://forum.dlang.org/thread/jquklsqxtfgvsezrcuzu forum.dlang.org?page=1 https://forum.dlang.org/post/yonbmhifafbyjhwpcixp forum.dlang.org
Jul 19 2023
On 19/07/2023 7:44 PM, Sergey wrote:Forking GC was introduced some time ago. But I don't think it is quite different from regular (https://forum.dlang.org/post/tf8mbo$1jvp$1 digitalmars.com)It is a modification of the conservative GC. Rather than a unique GC implementation and is upstreamed.There are some posts about it GCs, but I don't think anything was released. https://forum.dlang.org/thread/jquklsqxtfgvsezrcuzu forum.dlang.org?page=1 https://forum.dlang.org/post/yonbmhifafbyjhwpcixp forum.dlang.orgThe only GC design I know of that is semi-interesting is Rainer's concurrent GC for Windows. http://rainers.github.io/visuald/druntime/concurrentgc.html This has not been upstreamed.
Jul 19 2023
Its not as simple as porting to the API unfortunately. We don't have barriers of any kind, so that removes most GC designs you would want to use today. We are very close to maxing out what we can do as a result. A whole pile of logic is hidden in rt, so you have no choice but to either do the work to fix that, or recompile druntime with your GC.
Jul 19 2023
On Wednesday, 19 July 2023 at 08:27:18 UTC, Richard (Rikki) Andrew Cattermole wrote:Its not as simple as porting to the API unfortunately. We don't have barriers of any kind, so that removes most GC designs you would want to use today. We are very close to maxing out what we can do as a result. A whole pile of logic is hidden in rt, so you have no choice but to either do the work to fix that, or recompile druntime with your GC.I'm mostly a frontend person, but is what would need doing there? Is there any existing discussion about that?
Jul 19 2023
On 19/07/2023 9:02 PM, IchorDev wrote:On Wednesday, 19 July 2023 at 08:27:18 UTC, Richard (Rikki) Andrew Cattermole wrote:Not really, last time I tried, I didn't document what was hidden. Copying out the conservative GC, register it under a different name and getting that to compile and link without recompiling druntime would be a good place to begin without having to understand how GC's work.Its not as simple as porting to the API unfortunately. We don't have barriers of any kind, so that removes most GC designs you would want to use today. We are very close to maxing out what we can do as a result. A whole pile of logic is hidden in rt, so you have no choice but to either do the work to fix that, or recompile druntime with your GC.I'm mostly a frontend person, but is what would need doing there? Is there any existing discussion about that?
Jul 19 2023
On Wednesday, 19 July 2023 at 10:50:07 UTC, Richard (Rikki) Andrew Cattermole wrote:Copying out the conservative GC, register it under a different name and getting that to compile and link without recompiling druntime would be a good place to begin without having to understand how GC's work.That sounds pretty easy, but I don't really see how would that be particularly helpful to allowing a different style of GC to be registered?
Jul 19 2023
On 19/07/2023 11:13 PM, IchorDev wrote:On Wednesday, 19 July 2023 at 10:50:07 UTC, Richard (Rikki) Andrew Cattermole wrote:druntime supports registering of GC's not compiled with druntime. But because some of the machinery isn't available to you, you would have to recreate it. So in practice you cannot find a GC on the dub-registry to try it out. Even if one were to exist, you would have to do a new build of druntime/phobos special which isn't the easiest thing to do. https://github.com/dlang/dmd/blob/master/druntime/src/core/gc/registry.d#L39 Regardless, its a barrier to anyone wanting to try writing a GC to experiment with (or port one).Copying out the conservative GC, register it under a different name and getting that to compile and link without recompiling druntime would be a good place to begin without having to understand how GC's work.That sounds pretty easy, but I don't really see how would that be particularly helpful to allowing a different style of GC to be registered?
Jul 19 2023
On Wednesday, 19 July 2023 at 11:27:14 UTC, Richard (Rikki) Andrew Cattermole wrote:druntime supports registering of GC's not compiled with druntime. But because some of the machinery isn't available to you, you would have to recreate it.Oh right, so it's more of a matter of making GC-related code part of the GC implementation so that it's more convenient for others to build their own GC on top of it.So in practice you cannot find a GC on the dub-registry to try it out. Even if one were to exist, you would have to do a new build of druntime/phobos special which isn't the easiest thing to do.Just to confirm: would none of this would require *me* recompiling DRuntime at all, or is it that DRuntime would have to be modified to the point where anyone else registering a unique GC from user code wouldn't have to recompile DRuntime?
Jul 19 2023
On Wednesday, 19 July 2023 at 11:27:14 UTC, Richard (Rikki) Andrew Cattermole wrote:[...] you would have to do a new build of druntime/phobos special which isn't the easiest thing to do.Side remark: LDC ships with the ldc-build-runtime tool which should help the user a lot in building druntime/phobos. (downloads the correct source belonging to the specific compiler version, and then builds the libraries with user-specified flags, compilers, etc.) -Johan
Jul 19 2023
On 7/19/23 10:46 AM, Johan wrote:On Wednesday, 19 July 2023 at 11:27:14 UTC, Richard (Rikki) Andrew Cattermole wrote:This is very cool to know, I wasn't aware! -Steve[...] you would have to do a new build of druntime/phobos special which isn't the easiest thing to do.Side remark: LDC ships with the ldc-build-runtime tool which should help the user a lot in building druntime/phobos. (downloads the correct source belonging to the specific compiler version, and then builds the libraries with user-specified flags, compilers, etc.)
Jul 22 2023
On 7/19/23 3:24 AM, IchorDev wrote:So, D’s default garbage collector is the one named “conservative” in DRuntime… I see there’s also “manual” which doesn’t actually function as a GC, which is interesting. Nothing says what ProtoGC is… so I guess it’s useless. Has anyone ever published any custom GCs? A search through the dub package registry yielded nothing. How hard would it be to port (for instance) a Java GC to D’s interface?To answer the question about ProtoGC, it is a stub GC which will create the appropriate GC (based on runtime flags) when the first function that requires actually using the GC is called. It is actually the default GC. This was introduced to implement more pay-as-you-go runtime features. If you don't use the GC, no GC is created. If I recall correctly, you must attempt to allocate using the GC for the ProtoGC to do its thing. Everything else is just simple stubs (e.g. ProtoGC.free does nothing, since it can never allocate memory) -Steve
Jul 19 2023