From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id WIGVDlAcUmOGagEAbAwnHQ (envelope-from ) for ; Fri, 21 Oct 2022 06:13:04 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id oMKdDlAcUmOdbgEA9RJhRA (envelope-from ) for ; Fri, 21 Oct 2022 06:13:04 +0200 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 C9E97178E8 for ; Fri, 21 Oct 2022 06:13:03 +0200 (CEST) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oljP5-0008KI-0W for larch@yhetil.org; Fri, 21 Oct 2022 00:13:03 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oljLK-0006j9-SV for larch@yhetil.org; Fri, 21 Oct 2022 00:09:10 -0400 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 1oljLH-0006iw-W2 for emacs-orgmode@gnu.org; Fri, 21 Oct 2022 00:09:08 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oljLF-0007QZ-RU for emacs-orgmode@gnu.org; Fri, 21 Oct 2022 00:09:07 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id C2EB4240101 for ; Fri, 21 Oct 2022 06:09:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1666325343; bh=+uwKJ+wXb8j00Fkxp9hopTrTv3lWDa3rGIdpIiQYJZ4=; h=From:To:Cc:Subject:Date:From; b=XSfDENQkdbSz3k3R6ZrLW2caczuSXdnO2Q2CpGZKVbKv+BLhOVs3lMpMDZ9yjBevk RTqY9QMrRbvgrew/K6mbH03WuWbZPxtqrMJpKxHzCmno5XBQcftv/uEeIzAadCeHI8 7qrgtk7658joEkvuori0/Xq8+XOUHxRiu8MFRgL69ubCNhAAfCcdu+CeAvGXuoCKQk VqrbnkDaeYDTlumptfe1/Jhit/Tp6W7Ic0HG8Ni+NyLZDkyAk0LPzksAtgtFBcujZI sWV8LIyUqk7BP0bym65fvs3CH+zVOnf2rABsDCxkjswsfugv8l1bqIWKhe0iSA8dsX y1SPwJXKSJbYQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4MtrZ51VJ1z9rxH; Fri, 21 Oct 2022 06:09:00 +0200 (CEST) From: Ihor Radchenko To: Michael Eliachevitch Cc: Org Mode Subject: Re: org-persist-write slow when pp-use-max-width is t In-Reply-To: <87o7u6t9sm.fsf@posteo.de> References: <87o7u6t9sm.fsf@posteo.de> Date: Fri, 21 Oct 2022 04:09:45 +0000 Message-ID: <87y1t96cmu.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , 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=1666325583; 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=RnrcJx26V4r49mZrxkwPrJz0lmEthIelMb+eLFptYps=; b=hrpHADdugWF1EfzBHdJjJGT1cE4D6P+mM5aBXDKHk1JtSnjNHReYreEdq1j20t7TiUB3vL 4pR6omeLZ/HuLbnyeVP3gcFGM0uehnEwHcpk9/XaG0SZfu1mZ+jAdyMNRRbgsZ/8lLmDgl W53MH8gxSMdkqFIY9+6WuKSF6iQzITHNDB5wjtOKLEWOjv6ejdZG0P89/nVwDpZZft4zIi fsEmjBj1qKuyiOEeajD5QoKp98W5COVcz6HA0F6fs2NjbYRz/zDlKMIQo+OB/MI2H8m9HG inNGlZp12QkWHHAbLceeKKWQIgj6RqcZy02i7ylr8xnM+nicelQIxWCHbvHjKg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666325583; a=rsa-sha256; cv=none; b=Ho6OKEKXtN8KreXs+YHNktA8fCuO9TA/5iKAH8LSK0cKnqkNsvdlnkU/XmGolmbaiX4bYf 9ue9+IGqGkgHHuF4JapW/ZhsE3BsFASgs7JSdwXWkHI+1tgy8X2HvImjimJeynl6HH3fCp edj6+LON0xqry1rw/8DfHgaC8BeXO5FvXkaWUc1G5Ed/w6+GuFryzd3OXV4fTWI6BnHE6K C67l+lHcSbIyWEaV+NdI/uSzkwtHQF+mw4YEz6cn5xBScSLVSJlLYyBf12oYgabCqj5f2c vy8E+W/kkKiTvRu1rKlsTzzjF969dH0QTvSXghLoo8yDdv3Q7KRn4Xl9Fr8Raw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=XSfDENQk; dmarc=pass (policy=none) header.from=posteo.net; 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: -3.44 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=XSfDENQk; dmarc=pass (policy=none) header.from=posteo.net; 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: C9E97178E8 X-Spam-Score: -3.44 X-Migadu-Scanner: scn1.migadu.com X-TUID: hcVUeUZ+j3fi Michael Eliachevitch writes: > I was wondering why kill-emacs emacs takes over a minute and after some profiling I found out that the call to org-persist-write-all takes long when pp-use-max-width is set to t and pp-max-width is also set (in my case to t, the window-width), which enables line folding in pp. The pp-call happens in org-persist--write-elisp-file when it is called by org-persist-write:index with the pp-parameter set to t. Maybe it's clearer with the following excerpt of my CPU-profile: > > 38009 96% - org-persist-write-all > 38009 96% - org-persist-write > 37703 95% - mapcar > 37703 95% - # > 37703 95% - org-persist-write:index > 37703 95% - org-persist--write-elisp-file > 37703 95% - pp > 37703 95% - pp-to-string > 37703 95% - pp-emacs-lisp-code > 37687 95% + pp--insert-lisp > > Setting pp-use-max-width to nil made the function call almost instantanteous. > > I had enabled pp-use-max-width in the past when pretty-printing the results of interactive elisp sessions (like pp-eval-last-sexp). I didn't think this would affect how other packages would save their data and I didn't expect this would result in such a performance hit. Possibly this is not an issue with org-mode or pp but just my own mistake of not being aware that pp is used as a library by other packages and thus customizing its behaviour has global effects. > > Not sure if the org mailing list is the best place to report this observation. What org could do is to use a let-binding to temporarily set pp-use-max-width to nil to disable line folding. Or do you think that some users might care that their cache files are formatted prettily according to their customization options? > > If you think this is not an issue with org-mode, maybe I/we could forward this to the pp-maintainers, as it's in emacs core possibly to emacs-devel? I think at least a warning in the variable documentation about performance hits might have been helpful. Thanks for reporting! pp-max-width has been introduced in Emacs 29. The fact that pp becomes too slow is likely something to be fixed before the next Emacs release. While we can work around this issue on Org side, I'd prefer to ask Emacs developers first and see if they can come up with a fix. I suggest you to file a bug report to Emacs. You may provide the contents of your org-persist-index-file inside org-persist-directory. AFAIU, it is what is taking a lot of time to print. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at