From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id +HEwOH//vmGCwQAAgWs5BA (envelope-from ) for ; Sun, 19 Dec 2021 10:46:39 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 2IUONH//vmGsFwAA1q6Kng (envelope-from ) for ; Sun, 19 Dec 2021 09:46:39 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9079E1C912 for ; Sun, 19 Dec 2021 10:46:39 +0100 (CET) Received: from localhost ([::1]:44988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mysm6-0005az-Q6 for larch@yhetil.org; Sun, 19 Dec 2021 04:46:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mysla-0005ao-FI for emacs-orgmode@gnu.org; Sun, 19 Dec 2021 04:46:06 -0500 Received: from [2a00:1450:4864:20::131] (port=42840 helo=mail-lf1-x131.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1myslV-0000dj-2B for emacs-orgmode@gnu.org; Sun, 19 Dec 2021 04:46:06 -0500 Received: by mail-lf1-x131.google.com with SMTP id b22so14755020lfb.9 for ; Sun, 19 Dec 2021 01:46:00 -0800 (PST) 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=JjZehX0ntTfS9rorUEhTdZFQ9r2HuF62xNEXTl9xV8g=; b=fbzR1AccmAwy+3RPuaRrF2DB26sTVNZEujj1LikXzy91rvQE3snyHakgTozNWMT8NZ 1SpqjxpCAhU9BL3chCryYglu/AGo4u///vtF7X2z/vz2IzisbMABVhVlc6KBIkTareqv 7LrG/RHDWlcAE9INVBzzAE+ZtdrgARoEJhpx0LBkWkN8ljXuTFK9PyLkEfRwnUGBdi5G Y7Y//DNBehQmpctWJgWrlWf8bI0x5NBXmRVjy6cwK6xuglHrVKgxniHeltG0qVT8gGXR Bvb/E77Yr/ETVFCI0sWit6pCsd8Rg+ZpzJLED/U6GRievKfc91wksGoixc2bBNHPx5lc fo4Q== 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=JjZehX0ntTfS9rorUEhTdZFQ9r2HuF62xNEXTl9xV8g=; b=nnY51GNK9s9EjjNjULbRerCaHbBzyUyscZUtiIxaOrYUUytURB72pIBO8fGD9Lx6uK L5FKdgJWuVpqQx6SbEFLsEZ6lO9GxYgnXzw05Ragl/IUA35Z7u7+SsoyDqZ2znlx1oeG 3XKY8aB3UoaYy4jb7pOOEPQxPYFc+r6Zlx7aqZOmHm6mn7p+IhNhofJEcEbJQqRJS/wy tetjifX1gON6Ip4plc7scHzf+lNe9bpL4kcpQuqpTurJrEUjhgUn3L3M2qsg/LuWXls6 eUxo8bbum8/FD2OMqtjzpV0zuZ7OBP2mr2+chYTXoFQhrS/Iv1ehJG4a7vRj3tXjNrXu Vmug== X-Gm-Message-State: AOAM533hKQsU2y0vytMZu35ecxzmuuIXMF1sp2F1TZt2uvWu+4Wvusws wJopoaPDq8XlEfpvI4DOC88= X-Google-Smtp-Source: ABdhPJzT9b/CwMRjrCfrvxDV6pcUz4R3oyuX8LWzsv3Q0RaVgYPzwzijqOfiDhFQ073J4troDliNCw== X-Received: by 2002:a05:6512:39c7:: with SMTP id k7mr11191515lfu.571.1639907158954; Sun, 19 Dec 2021 01:45:58 -0800 (PST) Received: from localhost ([158.255.2.9]) by smtp.gmail.com with ESMTPSA id l8sm544420lfg.2.2021.12.19.01.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Dec 2021 01:45:58 -0800 (PST) From: Ihor Radchenko To: Kaushal Modi Subject: Re: [BUG] org-element--cache gives "Unregistered buffer modifications" warning [9.5 (9.5-g859984 @ /home/john/.emacs.d/straight/build/org/)] In-Reply-To: References: <87y25ztcgr.fsf@localhost> <87bl1hdvuj.fsf@localhost> <87mtl037ez.fsf@localhost> <878rwiil7c.fsf@localhost> Date: Sun, 19 Dec 2021 17:47:22 +0800 Message-ID: <87ee69rknp.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::131 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::131; envelope-from=yantar92@gmail.com; helo=mail-lf1-x131.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-org list , John Mathena Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1639907199; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=JjZehX0ntTfS9rorUEhTdZFQ9r2HuF62xNEXTl9xV8g=; b=kNU0eC7n0aSgOKsIBAdhFfZ5fz8yIjNjinJxgdNuxXQwLd/YTRrTDxzhXVQWnRiXX5ZCKj nfjZ0vwIid4U3Mkavhi49zi8WGaZnzQxU/wUvhQOAe2tP2dU/oGhhHMkMDbi5a8st7WpaK GR4U1hGFjBRb+u4j/Dya5edCITl2j3q/mGgpyTDdcktQjZgs9CD7lZa/Qf7ZjByp6HHKgi 03A7QCNbK7jFAJfrnpx+fjVAJaRj9LnIUJ6cbOJgg3EW5VCKvTLNu5yTRMSfMszsNSTyyD qCD35HMEWw8H1F+2wxWpO+l9f1KI74Q0FDJLW/9IFNnXatwNAIHa/jLCMjpoJA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1639907199; a=rsa-sha256; cv=none; b=rmcjX9Badsq+At8VsVzyd6a5I/tK4WZVnmtpT6mic/nruUDeEcIMyzNVMtoEwV0Gc5PpRk NHA3l5TTxP24ZBR8vpEZecy8MWQS/royE6VK6oS15p4VvJ8Di49LoETf3lb6EJMoPgydba ku7T7tUKUucVYhHkWarfsoezgtLcRIs0c+hbHrAopoVdgPlwiFjrYzUnvvbF5llzIW67CH T1DTWtCaSN8/4zIGSHObV1q6XOap9zTbRSIxxxrSFiMnfhKp/K1EhJ9cCm+2wU0FXzut4Z aKtkKdKqYJ4avpbRo8/RyEEErUj90ZkL3Xc1VA/Bzp9PXeI+sOm/RrGDAJLlgg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=fbzR1Acc; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -1.91 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=fbzR1Acc; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 9079E1C912 X-Spam-Score: -1.91 X-Migadu-Scanner: scn0.migadu.com X-TUID: lNrz36cW00x8 Kaushal Modi writes: >> On latest main, your example file is exported without any warnings. >> > > I just verified that. Also, I did not even need to add > `(org-element-cache-reset)' in `org-hugo--get-pre-processed-buffer' after > the `(insert ..)' in the temp buffer. > > Is that expected? Depends on your Emacs version. We had to disable the warning for Emacs<28 because some internal Emacs staff sometimes caused false-positives. However, if you tested using Emacs 28 or later, not seeing the warning is suspicious. > Let me know if you have any suggestions to improve the performance. I think > that the org-element-copy and writing the huge AST to temp Org buffer is > keeping the GC busy (the ox-hugo-manual.org is about 3700 lines right now). Just 145k buffer should normally cause no performance issues on Org side (on main). Even when you parse the whole buffer into AST. Problems begin around 5-10Mb. Yet, my 15Mb notes file is perfectly usable :D I looked through your `org-hugo--get-pre-processed-buffer': 1. org-element-copy should not be too much of an issue, unless you have many links. Yet, I am not sure why you need to use copy. You may as well modify the original element directly. 2. You call org-element-map twice making Org loop over the whole AST twice. 3. It is slightly more optimal to make your lambdas in org-element-map return nil. org-element-map allocates an extra list collecting all non-nil return values. If your lambda always returns nil, that list will not have to be created. Having said that, my local benchmarking did not show that org-hugo--get-pre-processed-buffer is a bottleneck. M-x profiler-start mostly revealed slowness of org-hugo--org-babel-exp-code, org-babel-expand-noweb-references, org-babel-sha1-hash, and org-macro-replace-all. Can you also try M-x profiler and see what is the bottleneck in your case? Best, Ihor