From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: MPS GC and its implications Date: Fri, 03 May 2024 14:54:29 +0300 Message-ID: <86h6ffi00a.fsf@gnu.org> References: <86jzkhu5rv.fsf@gnu.org> <87ttjlabic.fsf@gmail.com> <87v8408wsr.fsf@gmail.com> <87o79sasl5.fsf@gmail.com> <87plu72y8h.fsf@gmail.com> <877cgfwe5g.fsf_-_@gmail.com> <871q6mptkj.fsf@gmail.com> <86wmodofvw.fsf@gnu.org> <87frv1hclv.fsf@gmail.com> <86plu3i1nr.fsf@gnu.org> <87ikzvnnao.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21153"; mail-complaints-to="usenet@ciao.gmane.io" Cc: gerd.moellmann@gmail.com, acorallo@gnu.org, emacs-devel@gnu.org To: Helmut Eller Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri May 03 13:55:25 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s2rVa-00057q-Fw for ged-emacs-devel@m.gmane-mx.org; Fri, 03 May 2024 13:55:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s2rUp-00080O-OQ; Fri, 03 May 2024 07:54:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2rUn-0007zq-51 for emacs-devel@gnu.org; Fri, 03 May 2024 07:54:33 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2rUm-0002Uq-Sw; Fri, 03 May 2024 07:54:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=2mO4WpJl3viQdivAKCamEMqJsSDw0kVZBfRxXKxbohY=; b=oXtrDhmDakcAh9e9rkIx 5NTqAyfCCxb2UTa3sROBURiEII1ZVFIt5HYnwwuNxc9hzvTskjnHVMdisMen+HIfALNt8F4c01S0G cvSZPQhyCHEB1YwMPk0ayc7mEmooE2EO/TlINeNWjDxEJUdS+PdPqbHnmrqLqO6oKFo04Zce5tpZV q0wIFqK8nmQfNNkFRM4lEqVWsSlOYxYSjBQQSuDPO9KTd1C2BgA7gmFX0/hc24SvJzIGokMoW9vjw hqvWxqx8X2IFZRQ7pKkPb66yLynoPQEWIcjwVkOVxuaNnmBJSpU6DOtQS3Bovd99lDiM2f9B15CY0 KEZZayOxdpb23A==; In-Reply-To: <87ikzvnnao.fsf@gmail.com> (message from Helmut Eller on Fri, 03 May 2024 13:32:31 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:318666 Archived-At: > From: Helmut Eller > Cc: Gerd Möllmann , > acorallo@gnu.org, > emacs-devel@gnu.org > Date: Fri, 03 May 2024 13:32:31 +0200 > > On Fri, May 03 2024, Eli Zaretskii wrote: > > > I think this still leaves something unclear, at least to me. > > > > Let's say some Lisp thread in Emacs is running, and MPS decides to > > perform GC. AFAIU, the GC will run in a separate thread, right? So > > the question that bugs me is how does the GC thread and the Lisp > > thread synchronize so as to prevent the situation where GC moves an > > object in-between two accesses to the object by the Lisp thread? If > > the Lisp thread is stopped while GC runs, the answer is clear. But if > > the Lisp thread continues running concurrently with GC, I don't > > understand how this could possibly work, especially on a modern CPU > > with N > 1 execution units. In particular, how does MPS handle the > > time window between moving an object and updating all the references > > to the object, so that once an object is moved, all accesses to the > > object are redirected to the new location? If nothing is done, it is > > possible that a Lisp thread accesses the old address which is no > > longer valid, because the object was moved between the time the Lisp > > thread loaded the address into a register and the time it uses the > > address to access the object, but the address in the register was not > > yet updated. > > > > What am I missing? > > Memory barriers could be used for synchronization. When the mutator > hits a barrier, it executes the signal handler. The signal handler asks > the collector what to do. Essentially synchronizing those two. If this happens, I should have seen GDB intercept the exception and kick in. But it doesn't. (It also would have slowed the program quite a lot, I think.) > I don't know if MPS works quite like this, but it could. I'm not > worried about this issue. I'm worried because it sounds like we don't have a clear understanding how this stuff works, and without that we are basically stabbing in the dark when faced with a particular issue related to the MPS migration.