Re: [Pharo-dev] is there a way to know when a GC is happening?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-dev] is there a way to know when a GC is happening?

Eliot Miranda-2
 


On Wed, Sep 9, 2020 at 5:49 AM Stéphane Ducasse <[hidden email]> wrote:
>
> Hi
>
> I would to be able to see when an incremental GC is happening.

You can't.  All GC activity happens while the mutator (the rest of the Smalltalk VM) has stopped executing.  i.e. GC does not occur in parallel with the rest of the VM.
 
> is there a way to know when a GC is happening?

It is impossible, because effectively GCs happen between sends, and even between bytecodes.  But the VM collects statistics that show how many GCs of the various kinds have occurred and how much time has been sent in them  The statistics are made available through the vm parameterAt: primitives.  They are typically displayed in a SystemReporter dialog.  Here's an example from a Squeak image:

Virtual Machine Statistics
--------------------------
uptime 2d 5h 9m 56s (runtime 10h 27m 28s, idletime 1d 18h 42m 28s)
memory 238,690,304 bytes
old 229,738,272 bytes (96.2%)
young 7,190,528 bytes (3%)
used 198,213,464 bytes (83%)
free 32,454,736 bytes (13.6%)
GCs 110,155 (1737.5 ms between GCs 341.8 ms runtime between GCs)
full 115 totalling 17,644 ms (0.05% runtime), avg 153.4 ms
marking 6,600 ms (37.4%) avg 57.4 ms,
compacting 11,044 ms (62.6%) avg 96 ms
scavenges 110,040 totalling 68,213 ms (0.18% runtime), avg 0.6 ms
tenures 82,870,154 (avg 753 tenures per scavenge)
Code compactions
699 totalling 625 ms (0.002% runtime), avg 0.9 ms

These times were collected on a 2.9 GHz Intel Core i9 MacBook Pro.

A different question is can one be informed when a GC just happened?  The current answer is no, but it would be very easy to add.  In VisualWorks, for example, a WeakArray is primed with an Object instance, and this gets collected every scavenge.  So the WeakArray is notified.  From this VW builds a notification system.  I would engineer it differently.  If there is a Semaphore in either of two slots in the specialObjectsArray the VM could signal one Semaphore whenever a scavenge occurs and signal the other when a full GC occurs.

P.S>  can we please stop using the term "incremental GC" for a young space collection?  In Spur the young space GC is a classic Ungar-style scavenger, so I like to call these GCs scavenges.  Soon I hope that the Spur VM will have a proper incremental global GC. This will comprise a mark-sweep collector and a compactor fort old space, but both will operate incrementally.  The mark phase will be done in increments, allowing very small pause times as marking proceeds.  Likewise sweeping to free objects and especially compacting, to coalesce storage, will be done in small increments.  So there will be pause times of the order of 2 or 3 millisecondes due to the incremental collector and overall the system will avoid the relatively long pauses the global GC causes.

HTH
_,,,^..^,,,_
best, Eliot
Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-dev] is there a way to know when a GC is happening?

Stéphane Rollandin
 

>   Soon I hope that the
> Spur VM will have a proper incremental global GC. This will comprise a
> mark-sweep collector and a compactor fort old space, but both will
> operate incrementally.  The mark phase will be done in increments,
> allowing very small pause times as marking proceeds.  Likewise sweeping
> to free objects and especially compacting, to coalesce storage, will be
> done in small increments.  So there will be pause times of the order of
> 2 or 3 millisecondes due to the incremental collector and overall the
> system will avoid the relatively long pauses the global GC causes.

Excellent!

Stef