January 25, 2022
On Tuesday, 25 January 2022 at 03:37:57 UTC, Elronnd wrote:
> Apropos recent discussion, here is a serious question: would you pay for either of these?
>
> - High-throughput/scalable gc.  High sustained allocation rates, large heaps, many cores, compacting&generational
>
> - Concurrent gc.  No pauses

What you are going to hear is "I'd like someone else to do a bunch of work, and if it benefits me, I'll think about using it."

If you're serious about this, you should put together an extensive set of numbers demonstrating clear failure of D's garbage collector, failure of existing D solutions, and well-defined opportunities for improvement.
January 25, 2022
On Tue, Jan 25, 2022 at 02:24:48PM +0000, bachmeier via Digitalmars-d wrote:
> On Tuesday, 25 January 2022 at 03:37:57 UTC, Elronnd wrote:
> > Apropos recent discussion, here is a serious question: would you pay for either of these?
> > 
> > - High-throughput/scalable gc.  High sustained allocation rates, large heaps, many cores, compacting&generational
> > 
> > - Concurrent gc.  No pauses
> 
> What you are going to hear is "I'd like someone else to do a bunch of work, and if it benefits me, I'll think about using it."
> 
> If you're serious about this, you should put together an extensive set of numbers demonstrating clear failure of D's garbage collector, failure of existing D solutions, and well-defined opportunities for improvement.

+1.  Around these parts I hear a lot of complaints about GC this, GC that, but I've yet to see actual performance measurements that show just how bad the GC is.  It would be nice to see some actual numbers (and the actual code where the bad GC performance happens) that would show us just where D's GC is not up to the task, so that we have a concrete way of measuring any progress (or lack thereof) made on the GC.


T

-- 
The only difference between male factor and malefactor is just a little emptiness inside.
January 25, 2022

On 1/25/22 4:32 AM, Paulo Pinto wrote:

>

On Tuesday, 25 January 2022 at 08:24:22 UTC, rikki cattermole wrote:

>

On 25/01/2022 8:22 PM, Elronnd wrote:

>

On Tuesday, 25 January 2022 at 07:13:41 UTC, Paulo Pinto wrote:

>

ARC will also not compete, unless one goes the extra mile of making the compiler ARC aware, elide retain/release calls, do cascade deletions in background threads, take care on cascade deletions to avoid stack overflows on destructor calls, provide multicore friendly versions of them,.....

Indeed.  See Bacon et al, 'Unified Theory of Garbage Collection': increasingly sophisticated RC approaches tracing (and vice versa). So it's a bit strange to assume we can do one but not the other.  And tracing makes a better starting point due to the generational hypothesis.

RC shines for when deterministic destruction is required.

...

That is the naive idea, until a cascade deletion of a graph based datastructure happens.

I use ARC for determinism only, not memory deallocation: https://github.com/schveiguy/iopipe/blob/master/source/iopipe/refc.d

e.g., when I want the last reference to a buffered output stream to flush its buffer and close the file when going out of scope. I don't care about the memory management, that's fine for the GC to clean up.

As an added benefit, it's trivially @safe.

-Steve

January 25, 2022

On Tuesday, 25 January 2022 at 12:29:46 UTC, Paulo Pinto wrote:

> >

For a language like D you could have ARC + borrow checker + the ability to constrain ARC-pointers (to get a unique_ptr) for shared objects and something GC-like for objects local to actors/tasks.

In theory yes, in practice someone has to put down the money to make it happen and ensure that the performance gains are worth the money spent into it.

Actually, all it takes is for the core team to make it a priority. The existing GC can be taken as a starting point for local GCs, and you don't have to start with ARC, you can just start with well designed RC as a foundation to evolve from.

What is needed, to get this ball rolling as an open source project, is to focus on making the compiler more modular, especially the backend-interface.

So, I don't think this is a strict money issue.

Leadership needs to:

  1. provide a the clean compiler architecture that allows adding additional static analysis

  2. pick a memory management "coordination" design that can evolve in a open-source friendly manner (e.g. a protocol for purging unused/cached resources)

Only doable if leadership makes it a priority, as creating a better compiler architecture based on DMD is out of scope for individual contributors.

Without making memory management a priority, as a strategy, nothing will happen. And the reason for this is that good modern memory management requires solid static analysis and that is hard to add, for outsiders, to the current compiler architecture.

It is also clear that maintaining a separate branch of the compiler over time is not productive (given how D evolves, e.g. the sudden addition of import-C). It would be more satisfying to just create your own language then… Which many D users seem to do!!!

Given that last fact it becomes clear that this is not a money issue. People apparently find creating compiler tech enjoyable, if they have a good starting point to evolve from.

I don't think the D foundation necessarily has to provide a memory management solution that fits system level programming, but if it wants this to work as an well functioning open source project then the foundation must make sure that the core compiler infrastructure has well defined interfaces, and follows an open design philosophy, so that people can evolve solutions that fits their concrete projects and interests.

(Java had an advantage in having a well defined VM/IR that made it easy to build on for outsiders.)

January 25, 2022
On Tuesday, 25 January 2022 at 03:37:57 UTC, Elronnd wrote:
> Apropos recent discussion, here is a serious question: would you pay for either of these?
>
> - High-throughput/scalable gc.  High sustained allocation rates, large heaps, many cores, compacting&generational
>
> - Concurrent gc.  No pauses

No I wouldn't pay for any of those because that's not where the problem lies.

The problem is that the maintainers refuse to realize that the language/runtime are too limited and cannot support any of the proposed GC types.

D has two options, either add a managed pointers in the language or use library pointer types types (like C++, unique_ptr etc). Problem is that the runtime and standard library also needs to be changed in order to support switching GC types depending on wich route they take.

After the D project adds the necessary additions to support plug and play GC types, new GC types will emerge naturally as many people with start to tinker with new GC types.

January 26, 2022
After reading my book on GC, you're kinda right.

Right now a generational GC wouldn't be possible in D due to not having write barriers.

However this is not a language limitation and can be freely added to the compiler implementation as an opt-in solution. The GC interface of course is also freely modifiable and would too need to be modified.

Right now there is only two sort of wins I can see being possible.

1) Make the current conservative GC support snapshotting for concurrency on Windows.
2) Support a task/fiber aware GC. This will kinda give us a generational GC, without actually being a generational GC.

Either way, still no reason to think we need to change the language to make more advanced GC's possible.

Just to be clear, that book clearly states that a generational GC is not always the best solution. It is not worth complicating the language by adding a whole new pointer type just to make this possible even if it was required (which it absolutely isn't).
January 26, 2022

On Tuesday, 25 January 2022 at 07:13:41 UTC, Paulo Pinto wrote:

>

On Tuesday, 25 January 2022 at 06:13:31 UTC, Random Dude wrote:

>

On Tuesday, 25 January 2022 at 03:37:57 UTC, Elronnd wrote:

>

Apropos recent discussion, here is a serious question: would you pay for either of these?

  • High-throughput/scalable gc. High sustained allocation rates, large heaps, many cores, compacting&generational

  • Concurrent gc. No pauses

I'd pay to have it removed and replaced with ARC.

GC in it's current form can not compete with other more performant GCs and it shouldn't. D is in a unique position to enable people to write code as if they're writing python and also accommodate them when they want to do low-level optimizations.

If we could just have automatic reference counting both the GC and No-GC people would be happy. It's okay if that route changes how pointers work (metadata would have to be added and some code would break), this is the right move in the long run.

ARC will also not compete, unless one goes the extra mile of making the compiler ARC aware, elide retain/release calls, do cascade deletions in background threads, take care on cascade deletions to avoid stack overflows on destructor calls, provide multicore friendly versions of them,.....

If you are paying to replace GC with ARC, without putting the money to reach Swift level of performance (which is still pretty lame versus last gen tracing GCs in Java/.NET), then you will be getting lemons.

https://forums.swift.org/t/a-roadmap-for-improving-swift-performance-predictability-arc-improvements-and-ownership-control/54206

I can already see it, the forums being inundated with complains about ARC performance versus other languages.

Even then people are dissatisfied, apparently.

I asked Reddit why ARC isn't used more widely despite Swift being so successful and was swiftly(pun intended 😉) corrected that Swift user share has become 50% of what it once was at it's peak.

https://www.reddit.com/r/Compilers/comments/s6r9wo/pure_arc_in_a_low_levelprogramming_language/htpx4g1/?utm_medium=android_app&utm_source=share&context=3

January 26, 2022
On Tuesday, 25 January 2022 at 08:24:22 UTC, rikki cattermole wrote:
>
> On 25/01/2022 8:22 PM, Elronnd wrote:
>> On Tuesday, 25 January 2022 at 07:13:41 UTC, Paulo Pinto wrote:
>>> ARC will also not compete, unless one goes the extra mile of making the compiler ARC aware, elide retain/release calls, do cascade deletions in background threads, take care on cascade deletions to avoid stack overflows on destructor calls, provide multicore friendly versions of them,.....
>> 
>> Indeed.  See Bacon et al, 'Unified Theory of Garbage Collection': increasingly sophisticated RC approaches tracing (and vice versa).  So it's a bit strange to assume we can do one but not the other.  And tracing makes a better starting point due to the generational hypothesis.
>
> RC shines for when deterministic destruction is required.

In a small code base it might but in larger SW RC is on par with GC because it is impossible to keep track of all the references. You end up with leaks and dangling shared_ptrs because someone has a ref ... somewhere.

The best option in a large code base is RAII with value types until you cannot and then rely on unique_ptr equivalents that can only have a single owner at any one time (without hackery). Only RC/shared_ptr when you absolutely must have multiple owners and even then interrogate your design.
January 25, 2022
On Wed, Jan 26, 2022 at 02:09:24AM +0000, Tejas via Digitalmars-d wrote:
> On Tuesday, 25 January 2022 at 07:13:41 UTC, Paulo Pinto wrote:
[...]
> > If you are paying to replace GC with ARC, without putting the money to reach Swift level of performance (which is still pretty lame versus last gen tracing GCs in Java/.NET), then you will be getting lemons.
> > 
> > https://forums.swift.org/t/a-roadmap-for-improving-swift-performance-predictability-arc-improvements-and-ownership-control/54206
> > 
> > I can already see it, the forums being inundated with complains about ARC performance versus other languages.
> 
> Even then people are dissatisfied, apparently.
> 
> I asked Reddit why ARC isn't used more widely despite Swift being so successful and was **swiftly**(pun intended 😉) corrected that Swift user share has become 50% of what it once was at it's peak.
[...]

Cognitive dissonance. :-P


T

-- 
Try to keep an open mind, but not so open your brain falls out. -- theboz
January 26, 2022
On Wednesday, 26 January 2022 at 00:03:26 UTC, rikki cattermole wrote:
> After reading my book on GC, you're kinda right.

Thanks for the show of confidence :)


> 2) Support a task/fiber aware GC. This will kinda give us a generational GC, without actually being a generational GC.

Thread-local gc is a thing.  Good for false sharing too (w/real threads); can move contended objects away from owned ones.  But I see no reason why fibre-local heaps should need to be much different from thread-local heaps.

One java implementation used the high bits of the stack pointer as a thread identifier/tls pointer/etc.

I would like to see adaptive nursery size.  Good for non-fibre-based web stuff, also e.g. video games.  Imagine: you tell the GC every tick/request, and it tunes nursery size to 99%ile allocation size per frame.  Actual GC is pretty much free since all the stuff you allocated over the course of the frame is gone.  Then you have all the safety of the full GC approach, and nearly all the performance of the manual arena approach (and much better than malloc/free).