From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.devel Subject: Re: Opportunistic GC Date: Mon, 8 Mar 2021 07:20:28 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9354"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier , eliz@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Mar 08 08:22:36 2021 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 1lJADs-0002Mi-90 for ged-emacs-devel@m.gmane-mx.org; Mon, 08 Mar 2021 08:22:36 +0100 Original-Received: from localhost ([::1]:38354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJADr-0000MA-9Z for ged-emacs-devel@m.gmane-mx.org; Mon, 08 Mar 2021 02:22:35 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJACT-0008Jc-IR for emacs-devel@gnu.org; Mon, 08 Mar 2021 02:21:09 -0500 Original-Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]:38412) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJACP-0005e9-Rl; Mon, 08 Mar 2021 02:21:09 -0500 Original-Received: by mail-ot1-x334.google.com with SMTP id a17so8300821oto.5; Sun, 07 Mar 2021 23:21:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uGqSHlL020mF7NEKiwSZEJ1uklS5yaH1cwHdOMh+48A=; b=QS9ro1c0D12y1lDrS+DrtOjq70CbZ4ExOAQgYcqGOu6FqwAIu0q5RUTx1uOEXzTCzR R/4otZhd/TdjRlg77v3uMGv+6AzOCK7ZvkrgvhNQMLibGZgyIi6ot2/C9Lcq3AQryMIn G/vvi3wPp0zSTL8W4Y7NsCqsArEOgubVs9XxJKCOyrkluUTivIeKG5tq6DLHatppOs4d unQMYOL8ZsfofBdk3UcHChaE2ljgfmn6a8dmYYu8eCjhY7t/bt+Ui1rrvuMqimySVVsG lvlrEIqbckdVpvz+oJhhqK6bBlivgoRjFrvyftnQKIu0/wMUyHiOopejmAajNmJmSpVq p/bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uGqSHlL020mF7NEKiwSZEJ1uklS5yaH1cwHdOMh+48A=; b=LMc2d561QbItGKoHd0aHj8SY/G4NcaYtDz8st3GGDh5Hq+dbNiFTFQhV6AOxEFLYlO xe4jqLsrx86z9fHu2YAbUZ6ub9IgOtN7JIZUgPzEGf6YwJGbpiwlT45BFeIdMSn3maMU ySYGWBw/w0hDP5BHPPsUaRF8Q4/T34fFuOylQiVz3QTunuiL+cwjFmme4B7U6YHGkwbB CM/XIf07o5WB4ZK3Nv5Apqrnxg5KNuBukPaM2DxlyT1dSCtxp47almG8NYSC5TRlBekf pQLnrUhpbrWS3MKAXKvxTPtoLAduWFPIT4XZqMIbGvvGiJoys0SdxiU60ozjjMIIPu4a wxig== X-Gm-Message-State: AOAM530H2EevM/p56OGlR//VpppMPENl0iZoWvpjl3UfWR8K1L9pRbNe TqRtN0CKCSx8DspnPqZOE2ZPssRCA+F5tjxCvCY= X-Google-Smtp-Source: ABdhPJwNQ7Ht1vHHiMUreW1QSgM1viH4aLo8vjbVmabTr7xltIIiAuEqumFMyFmjeh1E6vOXrA3vcajDCuGarIh+CMM= X-Received: by 2002:a05:6830:1e51:: with SMTP id e17mr18546750otj.292.1615188064391; Sun, 07 Mar 2021 23:21:04 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::334; envelope-from=pipcet@gmail.com; helo=mail-ot1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.io gmane.emacs.devel:266161 Archived-At: On Mon, Mar 8, 2021 at 3:37 AM Stefan Monnier wrote: > I've been running with the code below recently to try and see if > opportunistic GC can be worth the trouble. Just a random idea: What if we exploit the fact most people have more than one CPU core these days, garbage-collect in a separate fork()ed process, then do only the sweeping in the main process? Immediate advantage: we'd never mark objects in the "real" Emacs process, making debugging easier. My implementation proposal would be to pipe(), fork(), run GC, then send through the pipe the Lisp_Objects which can be collected by the original Emacs. For me, it was a bit difficult to see that this would indeed be safe, but I'm now pretty convinced it would be: objects that are unreachable in the child Emacs cannot become reachable in the parent Emacs (they might show up on the stack, but that's a false positive). We'd have to be careful not to run two "real" GC processes at the same time. And, of course, we'd require fork() and pipe(), so I'm not sure this would work on Windows. Furthermore, if we ever decide to fall back to doing the real GC in the main process, we must not sweep objects which were determined to be unreachable by a conflicting henchman process. And of course it would mean that we would increase memory usage for GC, so in low-memory situations, we'd have to fall back to traditional GC. Eli, would this qualify as a "small" GC change, and thus be vetoed? Pip