From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.devel Subject: Re: Larger GC thresholds for non-interactive Emacs Date: Sat, 18 Jun 2022 13:35:04 +0800 Message-ID: <87bkuqwn3r.fsf@localhost> References: <87wndndbhq.fsf@gmail.com> <83bkuzznws.fsf@gnu.org> <877d5mqmkh.fsf@localhost> <83y1y2utnd.fsf@gnu.org> <87r13up587.fsf@localhost> <83o7yyur0l.fsf@gnu.org> <87leu2p3nu.fsf@localhost> <83leu2uewn.fsf@gnu.org> <87r13qv701.fsf@localhost> <83bkuursya.fsf@gnu.org> <87h74l9jk8.fsf@localhost> <83bkutqb3z.fsf@gnu.org> <9778F176-E724-4E61-B0FB-327BCDD316C0@acm.org> <87sfo4epeo.fsf@localhost> <87bkurrc5e.fsf@localhost> <87bkur72b7.fsf@gnus.org> <87r13n5muk.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28030"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , Mattias =?utf-8?Q?Engdeg=C3=A5rd?= , Eli Zaretskii , Tim Cross , rms@gnu.org, Alan Mackenzie , emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 18 07:35:49 2022 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 1o2R7d-00070K-PL for ged-emacs-devel@m.gmane-mx.org; Sat, 18 Jun 2022 07:35:49 +0200 Original-Received: from localhost ([::1]:53742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2R7c-0000fF-Gr for ged-emacs-devel@m.gmane-mx.org; Sat, 18 Jun 2022 01:35:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2R5r-0008H9-Vc for emacs-devel@gnu.org; Sat, 18 Jun 2022 01:34:00 -0400 Original-Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]:42733) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2R5q-0000JU-9C; Sat, 18 Jun 2022 01:33:59 -0400 Original-Received: by mail-qv1-xf34.google.com with SMTP id 88so5684152qva.9; Fri, 17 Jun 2022 22:33:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=eul2H/3LwsJgAJBSWMCfYF9tjJIu8oNoYI928gJuk2I=; b=hULQMnyPIIWF92L1b0cZXkTpgrL7StcWqi5+B8jTKW/85Hln/UG4UcO9OtxN3esggy 2d8+/m0lQtqonshDzZFG0qgFph+D1ffd/rUNJurhOAjB1W7mNyyka0CESeKhMaH9g3wp AGL2KtP0hUosD/v3WA9zL7eC+nflNTmZEQxDHz2bSbCVzJVlzeCEGY4MnibvGp2JiKNE 6xzIO2hjP46N2NbqrqAUCmaUJgV4b1FJbbCV7xorOPY1o7dctQ+knyIzaIeL3h8Yfnno ht7qJB57cfRBzQNumx/4b8WU1qaC6QBdcKxh/cfbgR4dLZYepvs98A946Hg/tg7t5GzS 5MLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=eul2H/3LwsJgAJBSWMCfYF9tjJIu8oNoYI928gJuk2I=; b=qTmdMlrcfX+99qvKOrtf3n2glh+iK2UIUNZ6eiS5ADAfqRF9TkDgRY8mRT9RcWKBe/ heGQ7Fplr921oyTl6zrfSQMCUcKPO3GMJRp7oid/evk2wqU6WQKvN/YKbysO1MkxdaCG C93pYGy1WN+08VseFf7YedYupKVrdGNpPLjI51FxXKnn1VLX/hJta++skCbknWn9vUKr xuZc89CyqjRTBA1exd4WHkPGyQEVskPmpaH/MjSRB+pt7upa2dmZcgt7Jrqg8Z5nv1RN 0zOihyjfQKqEuLE7weaUHS+GDfql+PFDK7u6ziQmdN+vLsE1C0Y6DufS8d6sfjpObsj0 WPHw== X-Gm-Message-State: AJIora+Y3+tCLYiqKWbHpN4DPF3cEoLCtYSsfGWAn/MUu2CgTyTzLzaj KSiMtFdGgwZ6w+ZzrrqWDHg= X-Google-Smtp-Source: AGRyM1twtCmhloUX/2W0E84rp5S2zrlYpygG3ee3Lxwr8Jd9EM1fg9I6ySRXgkRLjtzS+13tnKnyTA== X-Received: by 2002:ac8:7f82:0:b0:305:2987:28e7 with SMTP id z2-20020ac87f82000000b00305298728e7mr11450860qtj.273.1655530436357; Fri, 17 Jun 2022 22:33:56 -0700 (PDT) Original-Received: from localhost ([192.161.177.252]) by smtp.gmail.com with ESMTPSA id f5-20020a05620a280500b006a6a6f148e6sm5767548qkp.17.2022.06.17.22.33.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 22:33:55 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::f34; envelope-from=yantar92@gmail.com; helo=mail-qv1-xf34.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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" Xref: news.gmane.io gmane.emacs.devel:291330 Archived-At: Stefan Monnier writes: > BTW, I seen everyone's focused on `gc-cons-threshold` but that variable > does not adapt to the heap size, so maybe we'd be better off > playing with `gc-cons-percentage`. I am not sure if `gc-cons-percentage' is reliable. When we have a small heap (at the beginning of the batch command run), the GC will be triggered frequently. Later, after initial memory allocations for data structures is complete, the same `gc-cons-percentage' will make GC fire less frequently and will have nothing to do with actually allocated/deallocated memory objects in the subsequent parts of the batch process. Consider the following example: (defun init () (allocate-huge-hash-map-object)) (defun run () (dolist (...) (let (this and that) (query the huge hash-map)))) (init) (run) The (init) part will trigger frequent GCs yielding no of very small amount of garbage being collected. The (run) part may use more temporary allocations. Yet, GC will be triggered much less frequently simply because the atomic (let ...) allocations are small compared to the initially allocated hash-map object. I believe that gc-cons-threshold will still be useful as _an upper bound_ to trigger GC. gc-cons-percentage is probably more efficient when it triggers below gc-cons-threshold. Best, Ihor