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 15:04:32 +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="26251"; mail-complaints-to="usenet@ciao.gmane.io" Cc: eliz@gnu.org, Stefan Monnier , emacs-devel@gnu.org To: Andrea Corallo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Mar 08 16:06:09 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 1lJHSQ-0006cO-Pt for ged-emacs-devel@m.gmane-mx.org; Mon, 08 Mar 2021 16:06:06 +0100 Original-Received: from localhost ([::1]:39766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJHSP-0004u8-S9 for ged-emacs-devel@m.gmane-mx.org; Mon, 08 Mar 2021 10:06:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJHRZ-0004H0-CC for emacs-devel@gnu.org; Mon, 08 Mar 2021 10:05:13 -0500 Original-Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]:34254) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJHRW-0000Vy-1v; Mon, 08 Mar 2021 10:05:13 -0500 Original-Received: by mail-ot1-x331.google.com with SMTP id n23so3829125otq.1; Mon, 08 Mar 2021 07:05:09 -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=NVdUbPysVCZiJ/GFhKv+FHgRQG/BdKwuvDaxKiC82PA=; b=CqjGSeuiJjAJajO9RQWCU+V9WXtuBkFEbhwH+Hm4MQ//zqS/YoZcIwlH+WLhZx5Zp0 0ImTCxWCO0DruqwNKz85hEQSfPJPFhnbJqo4Id2AY7IoP55CtSDwQgxEK+3eNHloaPul AWFysQqM+soZlpzYo8A6PTq8yJVdMlWdhr3D+mPiBW8Yt+UZNHciRTZf9ixBDlZ4vZPe c0c2Odw2EN61US2q80+E+Nqx4jafMTwtrE5Aqqc00Tib9LwIhuTg4vR0KWdw1Mw09dqC xSYso2PPk+ffwzdFG+BVjFuq6HYORLd9Obd/FlPy16O144DByMX8ST4abqiiBnMe4XYN pGlw== 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=NVdUbPysVCZiJ/GFhKv+FHgRQG/BdKwuvDaxKiC82PA=; b=gmX4EJLNu6uycXBMtmyOFZhDUSDjMvAWPYJfhypS6R/piIgDq+5vlVuP5cOla3llxc M/qDsUicLoyYgQ1pU4SDSxTl4KAcm6xqKRw3I+exczY8U9pLwVFeChj3hJ7GdMVtMZBz sntMkA0zjm+1MkvO6uBpEJYTUIqlKeOd4k0MdS1a8oTJYax3vlwFyxa2ob2fEBrwTgpQ kdSmlBKHcbdgyuhLip37NfvDO9Xj16MdLIjQgSlAKSE0tDrApAL/W55q0YR1KO5sWScz mcl7IFFB/qHycJXybKX9s3Z4ymz79MEDg86eSB080YW3IIF+MLgJkh4Q2EANKSyWdc65 5VjA== X-Gm-Message-State: AOAM5314LG0iH8IhdL7OpSaVxI+SnNNTwDQSr4QQyQ8kgpv76OabJLQw D6xhC/b2cKG3n3iAv+hSNWPbhWNsWuI+wjxw9AU= X-Google-Smtp-Source: ABdhPJxkGd15+xJHR0yXitZZqDeIljBgEBz2Tio/V4tPwafEV4s9WLTsS+ZprsXnWKMhLNM360K2g8NVPE+mRaU82yE= X-Received: by 2002:a9d:6e8d:: with SMTP id a13mr4891006otr.287.1615215908641; Mon, 08 Mar 2021 07:05:08 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::331; envelope-from=pipcet@gmail.com; helo=mail-ot1-x331.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:266188 Archived-At: On Mon, Mar 8, 2021 at 2:01 PM Andrea Corallo wrote: > Pip Cet writes: > > > 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? > > It's an interesting concept, I thought about something similar in the > past but, I've two questions: > > Are we really sure that a non trivial process can long survive > or work as expected after being forked? I believe that, on all systems where bash works, we can expect fork() to behave. We do need to block signals, obviously, and must not do any real I/O in the subprocess (in particular, we must not unblock_input(), which I confess I did until just now). > Do we have (an efficient) fork on all supported systems? I'm not sure. I do know some systems prefer using spawn() to fork() + exec(), and I always suspected the main reason for that is because they do not have an efficient fork(). I do think that there should always be a runtime option to get the conventional synchronous GC, as that is bound to remain the faster option. As Eli points out, there are at least two significant use cases in which we have to use synchronous GC: low memory machines with large workloads, and limits on the number of processes we can launch. I believe single-thread machines are also likely not to benefit from it. But note that we already do launch quite a few asynchronous Emacs instances, on the native-comp branch. This would be just one, a short-lived one at that. Pip