Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #160324

Re: No, C is not a simple language

From "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Newsgroups comp.lang.c
Subject Re: No, C is not a simple language
Date 2021-04-24 12:48 -0700
Organization Aioe.org NNTP Server
Message-ID <s61slo$18a3$1@gioia.aioe.org> (permalink)
References (10 earlier) <s5nfpu$1ato$1@gioia.aioe.org> <s5u6f0$9vc$1@dont-email.me> <s5v7m4$1ess$1@gioia.aioe.org> <s5v81c$1ess$3@gioia.aioe.org> <20210423204204.51@kylheku.com>

Show all headers | View raw


On 4/23/2021 8:51 PM, Kaz Kylheku wrote:
> ["Followup-To:" header set to comp.lang.c.]
> On 2021-04-23, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
>> On 4/23/2021 12:37 PM, Chris M. Thomasson wrote:
>>> On 4/23/2021 3:10 AM, jacobnavia wrote:
>>>> Le 20/04/2021 à 23:07, Chris M. Thomasson a écrit :
>>>>
>>>>>
>>>>> For some reason, anytime I hear somebody go, just use a GC... Well,
>>>>> it makes think of this song:
>>>>>
>>>>> https://youtu.be/WJabPYimznY
>>>>>
>>>>> Or the following scene in Disney's Dragonslayer from 1981:
>>>>>
>>>>> https://youtu.be/TJRaLnLDMWg
>>>>
>>>> Great arguments!
>>>>
>>>> Technically sound, I am convinced now...
>>>>
>>>>
>>>> ... that you have nothing to say
>>>
>>> Have you ever had to deal with GC issues? I have... Unfortunately, some
>>> people seem to think that a full blown GC is okay to use for reclaiming
>>> memory in lock-free algorithms. It works, but can become a massive,
>>> nasty, unpredictable bottleneck. Only then do they complain. I warned
>>> some of them...
>>>
>>> https://youtu.be/XcxKIJTb3Hg
>>>
>>
>> I used to cringe when I would see code that would allocate nodes all
>> over the place, and never free them. Sometimes they would allocate nodes
>> in loops! They would say, ahhh, that's for the GC. WOW!
> 
> Allocating a node in the loop such that it is unreachable is actually a
> pretty easy situation for GC.

Ahhh yes. But I failed to give more context Kaz, sorry! Basically, the 
loop would receive events from observer threads, and create responses 
via allocating new nodes and pushing them into lock-free queues. The 
problem was that the frequency of this event loop would get "hot", and 
end up creating a shi% load of new nodes, not a free in sight. The GC 
would get radically loaded up.

> 
>    (while true
>      (cons x y))
> 
> The cons cell is allocated and immediately becomes unreachable.  Being
> unreachable it means that when GC is triggered, it does not have to
> traverse it.
> 
> Traversing the graph of reachable objects is a big expense.
> 
> It will have to sweep these cons cells to reclaim them. But that would
> have to be done by explicit memory management also!
> 
> Sweeping can be a big expense in a naive mark-and-sweep allocator.
> A generational garbage collector, though, makes the sweep cheaper.
> 
> A generational garbage collector will allocate these new cells into
> a "nursery" of baby objects.
> 
> When a certain limit is reached, a generational GC pass is triggered.
> The GC walks the object graph, but it avoids traversing across "mature"
> objects; it looks at areas like the machine registers and stack, looking
> only for baby objects.  It will not find any of these baby objects
> because only the loop is creating them, and it loses track of each one.
> 
> Then comes the generational sweep phase. Unlike in a full GC pass,
> the garbage collector only has to sweep through the nursery. The nursery
> is chock full of these cons cells made in the body of the loop. None
> of them were marked reachable, so they are deallocated.
> 
> This sweep pass does not have to look at any mature objects at all.
> 
> Basically, GC can be designed and tuned to deal with the pressure of a
> fast allocation of temporary objects that soon become garbage.
> Such cases arise in practical applications. For instance, macro
> expansion in Lisp. Or string processing. Or calculations with numbers
> that have to be boxed on the heap, like bignums and sometimes
> floating-point values.
> 

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-17 19:12 +0200
  Re: No, C is not a simple language silas poulson <Silas8642@hotmail.co.uk> - 2021-04-17 18:33 -0700
    Re: No, C is not a simple language Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2021-04-18 02:10 +0000
      Re: No, C is not a simple language silas poulson <Silas8642@hotmail.co.uk> - 2021-04-17 22:35 -0700
    Re: No, C is not a simple language Real Troll <real.troll@trolls.com> - 2021-04-18 17:00 +0100
      Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-18 21:52 +0200
  Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-18 16:46 +0000
    Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-18 20:30 +0200
      Re: No, C is not a simple language Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-04-18 12:46 -0700
        Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-18 22:53 +0200
        Re: No, C is not a simple language Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-04-19 04:20 -0700
          Re: No, C is not a simple language Thiago Adams <thiago.adams@gmail.com> - 2021-04-19 08:29 -0700
            Re: No, C is not a simple language Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-04-19 13:21 -0700
              Re: No, C is not a simple language Richard Damon <Richard@Damon-Family.org> - 2021-04-19 18:03 -0400
                Re: No, C is not a simple language Bart <bc@freeuk.com> - 2021-04-20 00:50 +0100
                Re: No, C is not a simple language David Brown <david.brown@hesbynett.no> - 2021-04-20 08:32 +0200
                Re: No, C is not a simple language Richard Damon <Richard@Damon-Family.org> - 2021-04-20 07:17 -0400
                Re: No, C is not a simple language David Brown <david.brown@hesbynett.no> - 2021-04-20 14:25 +0200
                Re: No, C is not a simple language Bart <bc@freeuk.com> - 2021-04-20 14:09 +0100
                Re: No, C is not a simple language Richard Damon <Richard@Damon-Family.org> - 2021-04-20 10:19 -0400
                Re: No, C is not a simple language James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-04-20 11:50 -0400
                Re: No, C is not a simple language Richard Damon <Richard@Damon-Family.org> - 2021-04-20 12:06 -0400
                Re: No, C is not a simple language James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-04-20 19:13 -0400
                Re: No, C is not a simple language Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-05-11 05:29 -0700
                Re: No, C is not a simple language David Brown <david.brown@hesbynett.no> - 2021-05-11 14:37 +0200
                Re: No, C is not a simple language Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-05-11 05:18 -0700
              Re: No, C is not a simple language Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-05-11 05:14 -0700
      Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-19 07:18 +0000
        Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-19 17:15 +0200
          Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-20 04:05 +0000
            Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-20 18:27 +0200
              Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-20 16:41 +0000
                Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-20 19:44 +0200
                Re: No, C is not a simple language Thiago Adams <thiago.adams@gmail.com> - 2021-04-20 11:04 -0700
                Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-20 20:23 +0200
                Re: No, C is not a simple language Thiago Adams <thiago.adams@gmail.com> - 2021-04-20 12:22 -0700
                Re: No, C is not a simple language Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-20 19:37 +0000
                Re: No, C is not a simple language Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-20 18:30 +0000
                Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-20 20:47 +0200
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-20 13:29 -0700
                Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-21 04:37 +0000
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-21 15:26 -0700
                Re: No, C is not a simple language Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2021-04-22 05:59 -0700
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-22 11:58 -0700
                Re: No, C is not a simple language Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2021-04-23 07:23 -0700
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-24 14:26 -0700
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-24 14:28 -0700
                Re: No, C is not a simple language Richard Damon <Richard@Damon-Family.org> - 2021-04-20 14:46 -0400
                Re: No, C is not a simple language Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-20 20:18 +0000
                Re: No, C is not a simple language Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-05-11 05:31 -0700
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-20 13:19 -0700
                Re: No, C is not a simple language Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-20 20:29 +0000
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-20 13:39 -0700
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-20 14:29 -0700
                Re: No, C is not a simple language Ian Collins <ian-news@hotmail.com> - 2021-04-21 08:56 +1200
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-20 14:07 -0700
                Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-23 12:10 +0200
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 12:37 -0700
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 12:38 -0700
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 12:43 -0700
                Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-23 22:38 +0200
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 13:44 -0700
                Re: No, C is not a simple language Ian Collins <ian-news@hotmail.com> - 2021-04-24 10:56 +1200
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 16:09 -0700
                Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 09:30 +0000
                Re: No, C is not a simple language Ian Collins <ian-news@hotmail.com> - 2021-04-30 21:11 +1200
                Re: No, C is not a simple language Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-24 03:51 +0000
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-24 12:48 -0700
                Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 09:24 +0000
                Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-26 21:24 +0200
                Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-27 07:26 +0000
                Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 09:27 +0000
                Re: No, C is not a simple language "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2021-04-20 19:53 +0200
                Re: No, C is not a simple language Thiago Adams <thiago.adams@gmail.com> - 2021-04-20 11:04 -0700
                Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 09:02 +0000
                Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-26 09:43 +0000
                Re: No, C is not a simple language Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2021-04-26 03:08 -0700
                Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 10:35 +0000
                Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-26 13:08 +0000
                Re: No, C is not a simple language Richard Damon <Richard@Damon-Family.org> - 2021-04-26 09:30 -0400
                Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 14:22 +0000
                Re: No, C is not a simple language scott@slp53.sl.home (Scott Lurndal) - 2021-04-26 18:57 +0000
                Re: No, C is not a simple language Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2021-04-26 06:55 -0700
                Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 14:15 +0000
                Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-27 04:37 +0000
                Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-27 07:22 +0000
  Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-19 21:42 -0700
    Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-22 00:26 -0700
  Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-28 00:02 -0700

csiph-web