emacs-devel
[Top][All Lists]
Advanced

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

Re: MPS: native comp


From: Andrea Corallo
Subject: Re: MPS: native comp
Date: Tue, 30 Apr 2024 06:52:45 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

Gerd Möllmann <gerd.moellmann@gmail.com> writes:

> Andrea Corallo <acorallo@gnu.org> writes:
>
>> Gerd Möllmann <gerd.moellmann@gmail.com> writes:
>>
>>> Andrea Corallo <acorallo@gnu.org> writes:
>>>
>>>> If the object was moved and the d_reloc is now updated by MPS I've a
>>>> doubt:
>>>>
>>>> What if our object (say d_reloc[x]) is loaded in a register by the
>>>> compiler?  How does the register gets updated by MPS?  In native code we
>>>> do this all the time for performance reasons.
>>>
>>> MPS traces registers and control stacks as ambig roots, so a reference
>>> from there makes the corresponding object immovable.
>>
>> I think I miss few bits to understand MPS:
>>
>> If stack and registers are scanned I guess MPS has to stop the mutator
>> thread no?  
>
> Yes.
>
>> In the moment after the mutator restarts after the scan other ambig
>> roots might appear, so how can such moving collection be done in a
>> parallel fashion?
>
> The exact algorith MPS implements I don't know either. The docs include
> some design documents, but I haven't read them all, and some I didn't
> understgand because there was some context missing.
>
> A number of possible algorithms that could be used are described in the
> literature, or one could glance at existing GCs for V8, for example.
> Hard to read though, for me at least.

I think is mandatory that at least some of us understand at least the
high level mechanism of how MPS works otherwise before of later we will
be beaten by it somehow.

My fear is that the GC requires the code is generated respecting some
property way we might not respect.  Other issues might rise in the
future if we don't understand all of this.

>> Also if this mechanism (I don't fully understand ATM) is working the
>> issue I mentioned of values being kept in registers should be a non
>> issue.  Code we generate from Lisp is not very different from the one we
>> compile form C (we still have registers spill/fills etc).
>
> Yes, I think the same. It's just like some C code running.
>
>>> Haha, I hadn't even remotely occurred to me that you would emit a
>>> comment with the name :-). That makes things a lot easier. 👍
>>
>> To survive I had to find my way somehow :)
>
> :-)
>
>>
>>>> I think the easiest is to to make objects loaded from native code non
>>>> movable.  Is this possible with MPS? What would be the downside of this?
>>>> They are very rarely collected anyway.  WDYT?
>>>
>>> I'd personally prefer to trace comp units in the usual way for Lisp
>>> objects, i.e. the fix_comp_unit.
>>>
>>> Main reason is simplicity. The tracing function is super simple, we only
>>> have to identify where in the comp unit data structure, or dylib,
>>> references exist that have to be traced. Registers/stack are not a
>>> problem (see above).
>>>
>>> Other reasons, not so important, but anyway, is reducing the number of
>>> roots. Every root adds to what MPS has to do. And ambig roots make
>>> objects immovable, which is somewhat against the spirit of a copying
>>> collector.
>>>
>>> Just my personal opinion, of course.
>>
>> Well other than spirit and possibly simplicity we should evaluate if
>> (and in case how much) is the cost to have this objects movable vs
>> non-movable.
>
> Sure.
>
> For me personally the most important aspect is interactive user
> experience. Let's say complaints about GC pauses are not entirelly
> unheard of ;-).

I totally second your opinion on this.  OTOH given we (well you 😅) are
doing the work now, is good we think about decision we are taking.

> I even have one myself: In an Org file, with my init.el,
> GC kicks in every 5 lines with C-n/C-p (something font/jit-locking
> produces heaps of garbage). It's unbearable, and that's on my old
> battlehorse MBPro with i7 from 2013 which I used for years for C++
> development in Linux VMs just fine :-/.
>
>> The starting point for me is that this is a very special kind of object
>> class we know in advance is very rarely (if ever) collected, so would be
>> a pity to not consider this in the definition of the GC strategy
>> (assuming is an option).
>
> MPS is also generational, i.e. objects eventually move to older
> generations which are less frequently collected. Haven't played with
> that knob though. Atm, there are 2 generations.

Yep, essentially we know that all objects coming from CUs should go
directly to the oldest generation by definition and we should not bother
moving them.

Thanks!

  Andrea

PS last week I failed compiling MPS :/ I hope I can retry in the future
and have a look.



reply via email to

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