emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: basic questions on MPS


From: Helmut Eller
Subject: Re: basic questions on MPS
Date: Sat, 27 Apr 2024 10:41:37 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

On Fri, Apr 26 2024, Richard Stallman wrote:

>   >   Can somebody explain what the
>   > problem with hardware based read barriers could be?
>
> What is a "read barrier"?

The definition from the MPS documentation is this:

 A read barrier is a block on reading from certain memory locations by
 certain threads or processes. Read barriers are used for incremental or
 concurrent garbage collection.

For a GC algorithm it is often useful to know the relatively small
subset of objects that are accessed (or written to) in a certain time
interval.  Memory barriers are the mechanism to identify this subset; at
least approximately.

This can be implemented with hardware or software (or a combination).
Hardware barriers use the MMU via syscalls.  Software barriers are a
data structure that must be updated on every read (or write) operation.
This requires compiler assistance or disciplined programmers.

>   > 3) MPS uses a mostly-copying strategy.  Copying works well for
>   > short-lived objects.  For long-lived objects it's not so great.  The big
>   > guys (OpenJDK, V8 etc.) switch to mark-compact or something else for
>   > older generations.
>
> Could you explain that statement a little?  "Older generations" of
> what?

A generational GC algorithm partitions objects by age.  The subsets are
called generations.  New objects are allocated in the first generation.
After a while, they are moved the second generation or, if they are no
longer referenced, they are reclaimed.  Those from the second generation
are moved to the third and so on.  The same idea can be expressed with
more colorful words: objects are born in the youngest generation, they
live for a while, they are promoted to the next older generation until
they die.

Generational GCs focus the attention on the young generation.  The older
generations are scanned much less frequently.

A copying GC identifies live objects, copies them to a new region and
those that stay behind are reclaimed.  This works extremely well for the
first generation because many objects are only needed temporarily and
don't need to be copied to the second generation.

However, some objects are moved to the older generations.  E.g. a data
structure that starts small but accumulates useful stuff incrementally.
Over time it will be come bigger and older.  Now, copying this big data
structure around for eternity could be problematic.  It would be better
just to keep it in place.  That's what the mark-compact algorithm does.

Helmut



reply via email to

[Prev in Thread] Current Thread [Next in Thread]