Thanks to visit codestin.com
Credit goes to github.com

Skip to content

GC Ballast / Task Ballast question #32

@hostilefork

Description

@hostilefork

I changed some code that started creating a lot of series--one per function call (though most of the time this series should just be GC'd). Unfortunately, tight loops wind up making quite a few before the GC has a chance to get called. So it's easy to hit high water marks in memory that don't get released.

There are some things that can be done about it, and I expected it to be a performance hit... but I saw something strange with it seeming to GC on just about every cycle. Then I saw this code here:

https://github.com/metaeducation/ren-c/blob/8d29c1169c69dc5b9e733bfe39fa7c0f7b3220dd/src/core/m-gc.c#L1244

The GC_Ballast has always been a bit of a mystery to me, and I imagine you have looked at it . But when I put some debugging code in to print out numbers at this point I got back things like this:

PG_Mem_Usage = 14515476
TASK_BALLAST = 60
GC_Ballast increased by half -52
Recycled 0
PG_Mem_Usage = 14515476
TASK_BALLAST = 90
GC Ballast cut in half 298
Recycled 2
PG_Mem_Usage = 14515476
TASK_BALLAST = 45
GC_Ballast increased by half -11
Recycled 0
PG_Mem_Usage = 14515476
TASK_BALLAST = 66
GC_Ballast left alone 114
Recycled 1
PG_Mem_Usage = 14515476
TASK_BALLAST = 66
GC_Ballast increased by half -46
Recycled 0
PG_Mem_Usage = 14515476
TASK_BALLAST = 99
GC_Ballast left alone 147

So it has gotten to the point where it is GC'ing very frequently with a tiny TASK_BALLAST that is just sort of flipping around at small numbers, and it's recycling one or 2 series at a time.

If you've looked at this code can you give some insight into what it should be doing? Is this expected behavior that it thinks 14 MB is too much and really won't keep going without a GC every cycle?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions