From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Raffael Stocker Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 29 Nov 2023 21:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 67536@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.170129347313141 (code B ref -1); Wed, 29 Nov 2023 21:32:02 +0000 Received: (at submit) by debbugs.gnu.org; 29 Nov 2023 21:31:13 +0000 Received: from localhost ([127.0.0.1]:51624 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8S9J-0003Pt-Co for submit@debbugs.gnu.org; Wed, 29 Nov 2023 16:31:13 -0500 Received: from lists.gnu.org ([2001:470:142::17]:44922) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8S9G-0003KJ-Uu for submit@debbugs.gnu.org; Wed, 29 Nov 2023 16:31:11 -0500 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 1r8S90-0001Af-UO for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 16:30:56 -0500 Received: from mail-out.m-online.net ([212.18.0.9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r8S8y-0005wG-Nq for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 16:30:54 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4SgXY75BPbz1qsP0 for ; Wed, 29 Nov 2023 22:30:19 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 4SgXY74DmBz1qqlS for ; Wed, 29 Nov 2023 22:30:19 +0100 (CET) X-Virus-Scanned: amavis at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavis, port 10024) with ESMTP id PW3vS2HFt88T for ; Wed, 29 Nov 2023 22:30:18 +0100 (CET) X-Auth-Info: 8TwOdn/C5t4VAAYPUyY3SkDRDhI0qO1AfYuFiJpGgGyjfCoAIfhAAcD8PNQt4Ssm Received: from Whiteflame (ppp-212-114-182-133.dynamic.mnet-online.de [212.114.182.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA for ; Wed, 29 Nov 2023 22:30:18 +0100 (CET) User-agent: mu4e 1.10.8; emacs 29.1 From: Raffael Stocker Date: Wed, 29 Nov 2023 22:29:38 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=212.18.0.9; envelope-from=r.stocker@mnet-mail.de; helo=mail-out.m-online.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Org table re-calculation is very slow, partly due to math-read-preprocess-string of calc mode consing unnecessarily. For example, in one (large) table, I get the following memory usage from the profiler: ... 60,252,646 96% - org-ctrl-c-ctrl-c 60,248,166 96% - org-table-calc-current-TBLFM 60,216,431 96% - funcall-interactively 60,205,119 96% - org-table-recalculate 49,094,651 78% - org-table-eval-formula 32,624,631 52% - calc-eval 32,624,631 52% - calc-do-calc-eval 32,620,487 52% - calc-do-calc-eval 32,611,151 52% - math-read-exprs 29,388,838 47% + math-read-preprocess-string 2,343,257 3% + math-read-expr-list ... The reason for the slow-down seems to be that math-read-preprocess-string conses a lot, keeping the GC busy. This is due to heavy use of replace-regexp-in-string in this function: (defun math-read-preprocess-string (str) "Replace some substrings of STR by Calc equivalents." (setq str (replace-regexp-in-string (concat "[" math-read-superscripts "]+") "^(\\&)" str)) (setq str (replace-regexp-in-string (concat "[" math-read-subscripts "]+") "_(\\&)" str)) (let ((rep-list math-read-replacement-list)) (while rep-list ;; consing like a mad-man here: (setq str (replace-regexp-in-string (nth 0 (car rep-list)) (nth 1 (car rep-list)) str)) (setq rep-list (cdr rep-list)))) str) I would like to propose using a temp buffer instead of kneading the string into submission: (defun math-read-preprocess-string (str) "Replace some substrings of STR by Calc equivalents." (with-temp-buffer (insert str) (goto-char 0) (while (re-search-forward (concat "[" math-read-superscripts "]+") nil t) (replace-match "^(\\&)")) (goto-char 0) (while (re-search-forward (concat "[" math-read-subscripts "]+") nil t) (replace-match "_(\\&)")) (goto-char 0) (let ((rep-list math-read-replacement-list)) (while rep-list (while (re-search-forward (nth 0 (car rep-list)) nil t) (replace-match (nth 1 (car rep-list)))) (goto-char 0) (setq rep-list (cdr rep-list)))) (buffer-string))) With this replacement, the profiler shows much less memory usage on the same org table: ... 30,411,804 91% - org-ctrl-c-ctrl-c 30,407,324 91% - org-table-calc-current-TBLFM 30,363,932 91% - funcall-interactively 30,331,900 91% - org-table-recalculate 20,430,223 61% - org-table-eval-formula 6,751,852 20% + org-table-justify-field-maybe 4,598,523 13% - calc-eval 4,586,091 13% - calc-do-calc-eval 4,569,619 13% - calc-do-calc-eval 4,547,971 13% - math-read-exprs 2,297,453 6% + math-read-expr-list 1,347,377 4% + math-read-preprocess-string 7,296 0% math-read-token ... Only I am not sure the replacement is correct in all possible edge cases (or whether it uses so much less memory because I have overlooked something). What do you think? Can a calc-mode expert weigh in here? Regards, Raffael From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 30 Nov 2023 07:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Raffael Stocker Cc: 67536@debbugs.gnu.org Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.17013276561214 (code B ref 67536); Thu, 30 Nov 2023 07:01:02 +0000 Received: (at 67536) by debbugs.gnu.org; 30 Nov 2023 07:00:56 +0000 Received: from localhost ([127.0.0.1]:52090 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8b2d-0000JV-S6 for submit@debbugs.gnu.org; Thu, 30 Nov 2023 02:00:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56142) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8b2b-0000JI-R2 for 67536@debbugs.gnu.org; Thu, 30 Nov 2023 02:00:54 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r8b2G-0007F5-JD; Thu, 30 Nov 2023 02:00:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=1Zi3JJFWqch06b+K3eqElGaO0GnL8HtAvhDG5WyUHQ8=; b=pII36Ustg1GC vhRU67pS4JB0nOYGZdaBnPW/P8g1TNTdCDlyMHOp1MFcWPadVgSGZanEY+thMPNKumcxqMBCtbjsT xz8EjzIuYs+aXHAvmg2f4/N3UrAQh5g3HgGlce/qSEwgWULV4bRm78nTVtRhGT95lN4qINcagQOgj BtUOOLZ91vDoyC7pVp74FzSlmm4xuY9kvzaz9YKVwFs3C1xRya0fyXpwOIkIRW4yCa1qub7SdNuJQ CIxBU72Y4RcGQluX3jhLKu2cqtd+pskFpdxpBPLnd9Fi/rJc194dEZBSeHLzresptenNKzO27jP8W yCSuhfdy/0u7aO8vNR8OQw==; Date: Thu, 30 Nov 2023 09:00:18 +0200 Message-Id: <83h6l367zx.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Raffael Stocker on Wed, 29 Nov 2023 22:29:38 +0100) References: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Raffael Stocker > Date: Wed, 29 Nov 2023 22:29:38 +0100 > > > Org table re-calculation is very slow, partly due to > math-read-preprocess-string of calc mode consing unnecessarily. For > example, in one (large) table, I get the following memory usage from the > profiler: > > ... > 60,252,646 96% - org-ctrl-c-ctrl-c > 60,248,166 96% - org-table-calc-current-TBLFM > 60,216,431 96% - funcall-interactively > 60,205,119 96% - org-table-recalculate > 49,094,651 78% - org-table-eval-formula > 32,624,631 52% - calc-eval > 32,624,631 52% - calc-do-calc-eval > 32,620,487 52% - calc-do-calc-eval > 32,611,151 52% - math-read-exprs > 29,388,838 47% + math-read-preprocess-string > 2,343,257 3% + math-read-expr-list This is not memory usage, this is CPU usage measured by using memory-allocation functions as triggers to probe for the function that is being executed. So its evidence about consing and GC pressure is indirect at best. Can you instead look at the values of gcs-done and gc-elapsed before and after running the offending code, and show the delta of each one of them, with and without your proposed changes? Then we will see a much more direct evidence about the number of GC cycles and the time spent in GC, and could make the decision about how to improve the situation. Thanks. From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Raffael Stocker Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 30 Nov 2023 19:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 67536@debbugs.gnu.org Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.170137092429077 (code B ref 67536); Thu, 30 Nov 2023 19:03:01 +0000 Received: (at 67536) by debbugs.gnu.org; 30 Nov 2023 19:02:04 +0000 Received: from localhost ([127.0.0.1]:54496 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8mIV-0007Ys-Hp for submit@debbugs.gnu.org; Thu, 30 Nov 2023 14:02:03 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:47688) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8mIS-0007YS-PJ for 67536@debbugs.gnu.org; Thu, 30 Nov 2023 14:02:01 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Sh5CL6nq9z1sBpn; Thu, 30 Nov 2023 20:01:50 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 4Sh5CL4sryz1qqlW; Thu, 30 Nov 2023 20:01:50 +0100 (CET) X-Virus-Scanned: amavis at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavis, port 10024) with ESMTP id 1j0Fodw37ad5; Thu, 30 Nov 2023 20:01:49 +0100 (CET) X-Auth-Info: QFlyvuzxXRic5dgVtXOVXjgrVwOTNyEDKcpdIHmQ6XgzniBgiVQ21VGwl3SUdXqH Received: from Whiteflame (ppp-212-114-182-107.dynamic.mnet-online.de [212.114.182.107]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 30 Nov 2023 20:01:49 +0100 (CET) References: <83h6l367zx.fsf@gnu.org> User-agent: mu4e 1.10.8; emacs 29.1 From: Raffael Stocker Date: Thu, 30 Nov 2023 19:28:27 +0100 In-reply-to: <83h6l367zx.fsf@gnu.org> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Eli Zaretskii writes: >> ... >> 60,252,646 96% - org-ctrl-c-ctrl-c >> 60,248,166 96% - org-table-calc-current-TBLFM >> 60,216,431 96% - funcall-interactively >> 60,205,119 96% - org-table-recalculate >> 49,094,651 78% - org-table-eval-formula >> 32,624,631 52% - calc-eval >> 32,624,631 52% - calc-do-calc-eval >> 32,620,487 52% - calc-do-calc-eval >> 32,611,151 52% - math-read-exprs >> 29,388,838 47% + math-read-preprocess-string >> 2,343,257 3% + math-read-expr-list > > This is not memory usage, this is CPU usage measured by using > memory-allocation functions as triggers to probe for the function that > is being executed. So its evidence about consing and GC pressure is > indirect at best. > > Can you instead look at the values of gcs-done and gc-elapsed before > and after running the offending code, and show the delta of each one > of them, with and without your proposed changes? Then we will see a > much more direct evidence about the number of GC cycles and the time > spent in GC, and could make the decision about how to improve the > situation. I defined the following advice: --8<---------------cut here---------------start------------->8--- (defun my-gc-status (orig-fun &rest args) (let* ((done-bf gcs-done) (elapsed-bf gc-elapsed) (res (apply orig-fun args)) (done-af gcs-done) (elapsed-af gc-elapsed)) (message "before:\n\tgcs-done: %d, gc-elapsed: %f" done-bf elapsed-bf) (message "after:\n\tgcs-done: %d, difference: %d\n\tgc-elapsed: %f, dif= ference: %f" done-af (- done-af done-bf) elapsed-af (- elapsed-af elapsed-bf)) res)) (advice-add 'org-table-recalculate :around #'my-gc-status) --8<---------------cut here---------------end--------------->8--- I had to put it around =E2=80=98org-table-recalculate=E2=80=99 instead of =E2=80=98math-read-preprocess-string=E2=80=99 as all the functions below org-table-recalculate are called very often and have small individual contributions. With the original =E2=80=98math-read-preprocess-string=E2= =80=99 I get the following typical result: --8<---------------cut here---------------start------------->8--- before: gcs-done: 854, gc-elapsed: 170.601313 after: gcs-done: 859, difference: 5 gc-elapsed: 171.671042, difference: 1.069729 --8<---------------cut here---------------end--------------->8--- I ran the command about twenty times and almost always got the gcs-done difference of 5, with the occasional 4. The gc-elapsed is fairly consistent at 1.07 for the 5 GC runs. The modified version yields this typical output: --8<---------------cut here---------------start------------->8--- before: gcs-done: 906, gc-elapsed: 181.417292 after: gcs-done: 908, difference: 2 gc-elapsed: 181.847972, difference: 0.430679 --8<---------------cut here---------------end--------------->8--- Again, the gcs-done difference is quite stable at 2, with the occasional 3, the gc-elapsed is also fairly consistent at 0.43 for the 2 GC runs. So we have about a factor of 2.5 between the elapsed GC times for the two versions. Regards, Raffael From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 30 Nov 2023 19:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Raffael Stocker Cc: 67536@debbugs.gnu.org Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.170137170330534 (code B ref 67536); Thu, 30 Nov 2023 19:16:01 +0000 Received: (at 67536) by debbugs.gnu.org; 30 Nov 2023 19:15:03 +0000 Received: from localhost ([127.0.0.1]:54509 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8mV5-0007wQ-FO for submit@debbugs.gnu.org; Thu, 30 Nov 2023 14:15:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33092) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8mV3-0007vZ-CU for 67536@debbugs.gnu.org; Thu, 30 Nov 2023 14:15:02 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r8mUo-0001RA-56; Thu, 30 Nov 2023 14:14:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=CtxOCRcNXyaRwJ5LcKr10VAcAjP4oxJyA7tHo0a0r1A=; b=e3mmcU/uP+XCVAhnw6bK Dub6Um9UPJ7bH3S+D1mS2BtpzR+M0DWqBEQWfv45sA/sa3fl8nHXhiQM2yFdhjM3aLAsdi/314BpR Z9SXoLbrcx3j7f3hkD99FjX7nOWMDcrAvDCcSpzHwDU6dfFNU9W3aZhvgHlamQwuT34Uvpp2NilmU Puorql709ocwo7gauobZkgak0bYPr7BfAWRBj+bZPQZIrYOCuwjAnqujkMoy/I4421og9NzhRLLOJ WFpIY71Ejbzc7LkHk7fRM2/RLVDwPQa2om7DNSo1BzOleFxX+W829Eeq0ccVXIeq770hcCHNs59A+ 2uQQrfP+I8Upmw==; Date: Thu, 30 Nov 2023 21:14:39 +0200 Message-Id: <83jzpzaw9s.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Raffael Stocker on Thu, 30 Nov 2023 19:28:27 +0100) References: <83h6l367zx.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Raffael Stocker > Cc: 67536@debbugs.gnu.org > Date: Thu, 30 Nov 2023 19:28:27 +0100 > > > (defun my-gc-status (orig-fun &rest args) > (let* ((done-bf gcs-done) > (elapsed-bf gc-elapsed) > (res (apply orig-fun args)) > (done-af gcs-done) > (elapsed-af gc-elapsed)) > (message "before:\n\tgcs-done: %d, gc-elapsed: %f" done-bf elapsed-bf) > (message "after:\n\tgcs-done: %d, difference: %d\n\tgc-elapsed: %f, difference: %f" > done-af (- done-af done-bf) > elapsed-af (- elapsed-af elapsed-bf)) > res)) > (advice-add 'org-table-recalculate :around #'my-gc-status) > > --8<---------------cut here---------------end--------------->8--- > > I had to put it around ‘org-table-recalculate’ instead of > ‘math-read-preprocess-string’ as all the functions below > org-table-recalculate are called very often and have small individual > contributions. With the original ‘math-read-preprocess-string’ I get the > following typical result: > > --8<---------------cut here---------------start------------->8--- > > before: > gcs-done: 854, gc-elapsed: 170.601313 > after: > gcs-done: 859, difference: 5 > gc-elapsed: 171.671042, difference: 1.069729 > > --8<---------------cut here---------------end--------------->8--- > > I ran the command about twenty times and almost always got the > gcs-done difference of 5, with the occasional 4. The gc-elapsed is > fairly consistent at 1.07 for the 5 GC runs. > > The modified version yields this typical output: > > --8<---------------cut here---------------start------------->8--- > > before: > gcs-done: 906, gc-elapsed: 181.417292 > after: > gcs-done: 908, difference: 2 > gc-elapsed: 181.847972, difference: 0.430679 > > --8<---------------cut here---------------end--------------->8--- > > Again, the gcs-done difference is quite stable at 2, with the occasional > 3, the gc-elapsed is also fairly consistent at 0.43 for the 2 GC runs. > > So we have about a factor of 2.5 between the elapsed GC times for the > two versions. Thanks, sounds like a good optimization to me. From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Raffael Stocker Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 01 Dec 2023 17:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 67536@debbugs.gnu.org Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.170145244117290 (code B ref 67536); Fri, 01 Dec 2023 17:41:01 +0000 Received: (at 67536) by debbugs.gnu.org; 1 Dec 2023 17:40:41 +0000 Received: from localhost ([127.0.0.1]:56052 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r97VJ-0004Uo-DC for submit@debbugs.gnu.org; Fri, 01 Dec 2023 12:40:41 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:45102) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r97VE-0004Uc-55 for 67536@debbugs.gnu.org; Fri, 01 Dec 2023 12:40:39 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4ShgLx3yshz1sB7f; Fri, 1 Dec 2023 18:40:25 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 4ShgLx1YfMz1qqlS; Fri, 1 Dec 2023 18:40:25 +0100 (CET) X-Virus-Scanned: amavis at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavis, port 10024) with ESMTP id mi8sfg2S79N7; Fri, 1 Dec 2023 18:40:24 +0100 (CET) X-Auth-Info: GBzBkj2/5SXMbsh9fLi642dVuwGbgj5vMwcDQGIzSc8eLLg8JTOSDKXb+RdKV5sn Received: from Whiteflame (ppp-212-114-182-156.dynamic.mnet-online.de [212.114.182.156]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 1 Dec 2023 18:40:24 +0100 (CET) References: <83h6l367zx.fsf@gnu.org> <83jzpzaw9s.fsf@gnu.org> User-agent: mu4e 1.10.8; emacs 29.1 From: Raffael Stocker Date: Fri, 01 Dec 2023 18:34:10 +0100 In-reply-to: <83jzpzaw9s.fsf@gnu.org> Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: > Thanks, sounds like a good optimization to me. Splendid! I cleaned it up a bit and ran a few tests against the original function using an empty string, a string without anything to replace and a string requiring many replacements. It seems to behave just as the original. I use cl-flet and (eval-when-compile (require 'cl-lib)). I hope that is ok. Regards, Raffael --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-calc-calc-aent.el-math-read-preprocess-string-c.patch Content-Description: optimized math-read-preprocess-string >From b3c055cfb42f45ffe662f4fa24ce7b0104949eb2 Mon Sep 17 00:00:00 2001 From: Raffael Stocker Date: Fri, 1 Dec 2023 18:24:59 +0100 Subject: [PATCH] * lisp/calc/calc-aent.el (math-read-preprocess-string): cons less (bug#67536) Use a temp buffer instead of working on a string. This function is called by calc-eval, which in turn is called repeatedly when re-calculating org-mode tables. This function is one of the main bottlenecks there. --- lisp/calc/calc-aent.el | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el index 66ede3295ae..84b580a7033 100644 --- a/lisp/calc/calc-aent.el +++ b/lisp/calc/calc-aent.el @@ -27,6 +27,7 @@ (require 'calc) (require 'calc-macs) +(eval-when-compile (require 'cl-lib)) ;; Declare functions which are defined elsewhere. (declare-function calc-digit-start-entry "calc" ()) @@ -550,19 +551,17 @@ math-read-subscripts ;;;###autoload (defun math-read-preprocess-string (str) "Replace some substrings of STR by Calc equivalents." - (setq str - (replace-regexp-in-string (concat "[" math-read-superscripts "]+") - "^(\\&)" str)) - (setq str - (replace-regexp-in-string (concat "[" math-read-subscripts "]+") - "_(\\&)" str)) - (let ((rep-list math-read-replacement-list)) - (while rep-list - (setq str - (replace-regexp-in-string (nth 0 (car rep-list)) - (nth 1 (car rep-list)) str)) - (setq rep-list (cdr rep-list)))) - str) + (with-temp-buffer + (cl-flet ((replace-all (regexp replacement) + (goto-char 0) + (while (re-search-forward regexp nil t) + (replace-match replacement)))) + (insert str) + (replace-all (concat "[" math-read-superscripts "]+") "^(\\&)") + (replace-all (concat "[" math-read-subscripts "]+") "_(\\&)") + (dolist (rep-elem math-read-replacement-list) + (replace-all (car rep-elem) (cadr rep-elem))) + (buffer-string)))) ;; The next few variables are local to math-read-exprs (and math-read-expr ;; in calc-ext.el), but are set in functions they call. -- 2.43.0 --=-=-=-- From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 01 Dec 2023 18:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Raffael Stocker Cc: 67536@debbugs.gnu.org Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.170145438820733 (code B ref 67536); Fri, 01 Dec 2023 18:14:01 +0000 Received: (at 67536) by debbugs.gnu.org; 1 Dec 2023 18:13:08 +0000 Received: from localhost ([127.0.0.1]:56063 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r980h-0005OJ-OG for submit@debbugs.gnu.org; Fri, 01 Dec 2023 13:13:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60510) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r980f-0005Nm-Gh for 67536@debbugs.gnu.org; Fri, 01 Dec 2023 13:13:07 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r980Q-0001Wv-Eo; Fri, 01 Dec 2023 13:12:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=+k9uiBcUqfHTDyFNSp/S0dgKe4BQCaUTG/bRK9jWnUs=; b=di3T9y0ALNZb sIyvzbTQ5lSYIN2qPWydKBFDYH3AJ5xOdjZTQWVL+u6ijtKAH+etFpWvBzHuQjJ4KXR7o+FJsR9VS UN1DE/oH+8Xfv6ZQCc+cfY52dmzNFfJLih0frkD4Nd2QFsdxRAvz697qXkZTFkDtU46T3bJcwso88 80T9IpjqOMvALiqRQGlAcZb6SUA0Fb1F4eYwmsj/XFnmkaWK2uiTYK4WsaW4pkIOFODLmr+VyJMJn 0X+59JvYTTaqvUknzz53O9PnC8qpuDf8Zo/P63D/BRllJwBSxDoDRyKn0HO6sb4QgQ7N27+GZLrv2 lDt5qv8uR7+QNGxXS/JAvw==; Date: Fri, 01 Dec 2023 20:12:46 +0200 Message-Id: <834jh1aj1d.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Raffael Stocker on Fri, 01 Dec 2023 18:34:10 +0100) References: <83h6l367zx.fsf@gnu.org> <83jzpzaw9s.fsf@gnu.org> X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Raffael Stocker > Cc: 67536@debbugs.gnu.org > Date: Fri, 01 Dec 2023 18:34:10 +0100 > > I cleaned it up a bit and ran a few tests against the original function > using an empty string, a string without anything to replace and a string > requiring many replacements. It seems to behave just as the original. Thanks. > I use cl-flet and (eval-when-compile (require 'cl-lib)). I hope that is > ok. I'd prefer a simple internal function, or a lambda. > + (with-temp-buffer > + (cl-flet ((replace-all (regexp replacement) > + (goto-char 0) > + (while (re-search-forward regexp nil t) > + (replace-match replacement)))) > + (insert str) > + (replace-all (concat "[" math-read-superscripts "]+") "^(\\&)") > + (replace-all (concat "[" math-read-subscripts "]+") "_(\\&)") > + (dolist (rep-elem math-read-replacement-list) > + (replace-all (car rep-elem) (cadr rep-elem))) > + (buffer-string)))) I think buffer-substring-no-properties would be better than buffer-string, as we don't need to copy any text properties, right? From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Raffael Stocker Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 01 Dec 2023 21:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 67536@debbugs.gnu.org Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.17014653277686 (code B ref 67536); Fri, 01 Dec 2023 21:16:02 +0000 Received: (at 67536) by debbugs.gnu.org; 1 Dec 2023 21:15:27 +0000 Received: from localhost ([127.0.0.1]:56205 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9Ar8-0001zt-I8 for submit@debbugs.gnu.org; Fri, 01 Dec 2023 16:15:26 -0500 Received: from mail-out.m-online.net ([2001:a60:0:28:0:1:25:1]:58699) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9Ar6-0001zj-6J for 67536@debbugs.gnu.org; Fri, 01 Dec 2023 16:15:26 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Shm6n5hfyz1s95D; Fri, 1 Dec 2023 22:15:13 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 4Shm6n3rbkz1qqlS; Fri, 1 Dec 2023 22:15:13 +0100 (CET) X-Virus-Scanned: amavis at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavis, port 10024) with ESMTP id 0sEfaQSnbwMT; Fri, 1 Dec 2023 22:15:12 +0100 (CET) X-Auth-Info: TSb3PVXAq9YVbyqVADZRtsZRWJd/j6PglpL/NBl1ctVqUCi+mJrsOJ0FUklgsyLk Received: from Whiteflame (ppp-212-114-182-156.dynamic.mnet-online.de [212.114.182.156]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 1 Dec 2023 22:15:12 +0100 (CET) References: <83h6l367zx.fsf@gnu.org> <83jzpzaw9s.fsf@gnu.org> <834jh1aj1d.fsf@gnu.org> User-agent: mu4e 1.10.8; emacs 29.1 From: Raffael Stocker Date: Fri, 01 Dec 2023 22:10:22 +0100 In-reply-to: <834jh1aj1d.fsf@gnu.org> Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> I use cl-flet and (eval-when-compile (require 'cl-lib)). I hope that is >> ok. > > I'd prefer a simple internal function, or a lambda. I went with the lambda, it is the more concise choice. >> + (buffer-string)))) > > I think buffer-substring-no-properties would be better than > buffer-string, as we don't need to copy any text properties, right? Yes, indeed. I fixed that too. Regards, Raffael --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-calc-calc-aent.el-math-read-preprocess-string-c.patch Content-Description: optimized math-read-preprocess-string >From 68ae1e20ae5eb66cc4899a1e442dae3bb6a054ad Mon Sep 17 00:00:00 2001 From: Raffael Stocker Date: Fri, 1 Dec 2023 22:08:24 +0100 Subject: [PATCH] * lisp/calc/calc-aent.el (math-read-preprocess-string): cons less (bug#67536) Use a temp buffer instead of working on a string. This function is called by calc-eval, which in turn is called repeatedly when re-calculating org-mode tables. This function is one of the main bottlenecks there. --- lisp/calc/calc-aent.el | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el index 66ede3295ae..b79765fbc1f 100644 --- a/lisp/calc/calc-aent.el +++ b/lisp/calc/calc-aent.el @@ -550,19 +550,16 @@ math-read-subscripts ;;;###autoload (defun math-read-preprocess-string (str) "Replace some substrings of STR by Calc equivalents." - (setq str - (replace-regexp-in-string (concat "[" math-read-superscripts "]+") - "^(\\&)" str)) - (setq str - (replace-regexp-in-string (concat "[" math-read-subscripts "]+") - "_(\\&)" str)) - (let ((rep-list math-read-replacement-list)) - (while rep-list - (setq str - (replace-regexp-in-string (nth 0 (car rep-list)) - (nth 1 (car rep-list)) str)) - (setq rep-list (cdr rep-list)))) - str) + (with-temp-buffer + (insert str) + (mapc (lambda (rep-pair) + (goto-char 0) + (while (re-search-forward (car rep-pair) nil t) + (replace-match (cadr rep-pair)))) + `((,(concat "[" math-read-superscripts "]+") "^(\\&)") + (,(concat "[" math-read-subscripts "]+") "_(\\&)") + ,@math-read-replacement-list)) + (buffer-substring-no-properties (point-min) (point-max)))) ;; The next few variables are local to math-read-exprs (and math-read-expr ;; in calc-ext.el), but are set in functions they call. -- 2.43.0 --=-=-=-- From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 02 Dec 2023 08:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Raffael Stocker , Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , Stefan Monnier Cc: 67536@debbugs.gnu.org Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.170150425530831 (code B ref 67536); Sat, 02 Dec 2023 08:05:01 +0000 Received: (at 67536) by debbugs.gnu.org; 2 Dec 2023 08:04:15 +0000 Received: from localhost ([127.0.0.1]:56611 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9Kz0-00081C-QN for submit@debbugs.gnu.org; Sat, 02 Dec 2023 03:04:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59952) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9Kyz-000811-MT for 67536@debbugs.gnu.org; Sat, 02 Dec 2023 03:04:14 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r9Kyj-0005dY-Pr; Sat, 02 Dec 2023 03:03:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=rMrPgzdeyn4uHWJhIvgRHfmILwb8ama05nzPrUtSXkY=; b=DwgRt/CaGnyRlR7Ny0xq OxCTCz2gJZE/JtXviCVnh45BSb3N8vII9gKDUEzU602pmXulI96vECnU1t8zjdYibsPee4Ni6a7l5 SQLRwS0WKcFRM+eJxAomOpRHddNxNxAopF2QTMOw4N6AiddTp1JZ6N8sXIRqUnsp+pu7ZYBNyQgjw WqgXVCvd/MrT+DolUxAD9TOBhHJACnJOeYoU3geQObS1RvrXmCBmUBWgn5E+M5yiFHeXOjWCCXkZ0 /kYnquwGeAPOCgD5pX6+KUiNlAt2C+kk7fi4FosQb1EiJZqZMMG777UeoyqMd/qD2lCYrIaqsUEca 2dV/tJAJq4J6sA==; Date: Sat, 02 Dec 2023 10:03:53 +0200 Message-Id: <83lead81zq.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Raffael Stocker on Fri, 01 Dec 2023 22:10:22 +0100) References: <83h6l367zx.fsf@gnu.org> <83jzpzaw9s.fsf@gnu.org> <834jh1aj1d.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Raffael Stocker > Cc: 67536@debbugs.gnu.org > Date: Fri, 01 Dec 2023 22:10:22 +0100 > > Eli Zaretskii writes: > > >> I use cl-flet and (eval-when-compile (require 'cl-lib)). I hope that is > >> ok. > > > > I'd prefer a simple internal function, or a lambda. > > I went with the lambda, it is the more concise choice. > > >> + (buffer-string)))) > > > > I think buffer-substring-no-properties would be better than > > buffer-string, as we don't need to copy any text properties, right? > > Yes, indeed. I fixed that too. Thanks. Mattias, any comments, or should I install this? From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 02 Dec 2023 14:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 67536@debbugs.gnu.org, Stefan Monnier , Raffael Stocker Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.170152903415574 (code B ref 67536); Sat, 02 Dec 2023 14:58:01 +0000 Received: (at 67536) by debbugs.gnu.org; 2 Dec 2023 14:57:14 +0000 Received: from localhost ([127.0.0.1]:58399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9RQg-000437-58 for submit@debbugs.gnu.org; Sat, 02 Dec 2023 09:57:14 -0500 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]:57842) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9RQe-00042w-9I for 67536@debbugs.gnu.org; Sat, 02 Dec 2023 09:57:12 -0500 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-50bc8a9503fso4244051e87.3 for <67536@debbugs.gnu.org>; Sat, 02 Dec 2023 06:57:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701529017; x=1702133817; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:from:to:cc:subject:date:message-id:reply-to; bh=f7yXxCjep27h03xgXglg3fkEdb5ca36KxgX2FR6/wkI=; b=U86yU09bAXsYWldoGJ0wbhxTmd6KZYMWxipVRhsk1Y4541JKLU0QSpQC4ZVTdeUxlq jt3HzpqRZICQ5VuUAITweNGGBljNtBaXrnIaxoBwXffh7rxJiX/qyn5bDChmqNxUvCIQ m+ex6el9lGRtRmqlwRfcmehuBUPvJh3lswAoiKLJwnoaP6dwGJGBGUEhFmzqdTHlskJI 3ONX/v4MkszV1MHa90U4Rl0QkAFQCQh3XRCtil4ABJ3SSH+jFN8pBRGEKQKtZgYpaS3E JUrMXjQyklVgAeMJQLdJJJc7Fd5fEJJadfmgj63J8FYGheBCe1sSwrMhueMx1Fp/CYZr TTxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701529017; x=1702133817; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=f7yXxCjep27h03xgXglg3fkEdb5ca36KxgX2FR6/wkI=; b=EttVHSLe1byMN093SzNbMLgWNhxiUqpKcNxsTaWJWyeBVfoerbDX8a+FHZjnu1DJ2i XEkFOBPc0/A4pyMRt8s6FV4tvSmK7ffbwsP0ySMXHjcaS0a7Ef1g/fKWgCmN0R7ifzG0 xCAIYVwUbefRjapF+el93vN2LACvtr5jxs2YHRexBznpnCicpjmvau1gRVlPIPRF4JQF MOK6/lVLOQCPBTWu4tnpXTQGGGlPs7fjqVVNtQ6AeLVICPy4YJOYrEqOfQQ6/GXnpF4i bu8oMiA90fFG5dmFRH/Eom638f4yC8XtAPCymBNQI5osZQu0zOaBvN2LpzwYqvno90CJ D8IA== X-Gm-Message-State: AOJu0YxaU8grO2lnGJb/eYSIQ5ifpnycqcyOJ74CjY3p0Bxe7ZwDlmtr TY/hh1yTk3z5EC6mYHBsPJI= X-Google-Smtp-Source: AGHT+IFpU1YBDuSZ5LJPYmfkTBnAGZX7iJ9dccfJfw4PhG4Wjs+/gg0fitJsp26CqKED5fMc6iH7iQ== X-Received: by 2002:a19:2d1b:0:b0:50b:d764:87fb with SMTP id k27-20020a192d1b000000b0050bd76487fbmr1629509lfj.71.1701529016471; Sat, 02 Dec 2023 06:56:56 -0800 (PST) Received: from smtpclient.apple (c188-150-165-235.bredband.tele2.se. [188.150.165.235]) by smtp.gmail.com with ESMTPSA id q25-20020a056512211900b004fb7359ab83sm244667lfr.80.2023.12.02.06.56.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Dec 2023 06:56:56 -0800 (PST) From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Message-Id: Content-Type: multipart/mixed; boundary="Apple-Mail=_BB5A896F-CC0D-4C80-BF01-B61DBAA77C7D" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Date: Sat, 2 Dec 2023 15:56:54 +0100 In-Reply-To: <83lead81zq.fsf@gnu.org> References: <83h6l367zx.fsf@gnu.org> <83jzpzaw9s.fsf@gnu.org> <834jh1aj1d.fsf@gnu.org> <83lead81zq.fsf@gnu.org> X-Mailer: Apple Mail (2.3654.120.0.1.15) X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_BB5A896F-CC0D-4C80-BF01-B61DBAA77C7D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 2 dec. 2023 kl. 09.03 skrev Eli Zaretskii : > Mattias, any comments, or should I install this? Well, the patch doesn't look too unreasonable so installing it would = leave us better off than before. Of course we may want to try to do better if this is really a = bottleneck. The big job was to detect and locate the inefficiency -- = thank you, Raffael! -- so his efforts were instrumental in any case. There are minor points that could be addressed: `mapc` is often better = replaced with `dolist`; the first position of a buffer is 1, not 0; and = perhaps iterating through all elements of math-read-replacement-list = isn't ideal. Here's a variant which computes a single regexp to do the job and should = cons a bit less. Raffael, maybe you could see if this makes a difference in Org table = performance. --Apple-Mail=_BB5A896F-CC0D-4C80-BF01-B61DBAA77C7D Content-Disposition: attachment; filename=math-read-preprocess-string.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="math-read-preprocess-string.diff" Content-Transfer-Encoding: quoted-printable diff=20--git=20a/lisp/calc/calc-aent.el=20b/lisp/calc/calc-aent.el=0A= index=2066ede3295ae..4c1c464512a=20100644=0A---=20= a/lisp/calc/calc-aent.el=0A+++=20b/lisp/calc/calc-aent.el=0A@@=20-547,22=20= +547,36=20@@=20math-read-subscripts=0A=20=20=20= "=E2=82=80=E2=82=81=E2=82=82=E2=82=83=E2=82=84=E2=82=85=E2=82=86=E2=82=87=E2= =82=88=E2=82=89=E2=82=8A=E2=82=8B=E2=82=8D=E2=82=8E"=20;=20= 0123456789+-()=0A=20=20=20"A=20string=20consisting=20of=20the=20= subscripts=20allowed=20by=20Calc.")=0A=20=0A+(defvar=20= math--read-preprocess-re-cache=20nil=0A+=20=20"Cached=20regexp=20and=20= tag:=20(REGEXP=20REPLACEMENTS=20SUPERSCRIPTS=20SUBSCRIPTS)")=0A+=0A=20= ;;;###autoload=0A=20(defun=20math-read-preprocess-string=20(str)=0A=20=20= =20"Replace=20some=20substrings=20of=20STR=20by=20Calc=20equivalents."=0A= -=20=20(setq=20str=0A-=20=20=20=20=20=20=20=20(replace-regexp-in-string=20= (concat=20"["=20math-read-superscripts=20"]+")=0A-=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20"^(\\&)"=20str))=0A-=20=20(setq=20str=0A-=20=20=20=20=20=20=20=20= (replace-regexp-in-string=20(concat=20"["=20math-read-subscripts=20"]+")=0A= -=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20"_(\\&)"=20str))=0A-=20=20(let=20= ((rep-list=20math-read-replacement-list))=0A-=20=20=20=20(while=20= rep-list=0A-=20=20=20=20=20=20(setq=20str=0A-=20=20=20=20=20=20=20=20=20=20= =20=20(replace-regexp-in-string=20(nth=200=20(car=20rep-list))=0A-=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(nth=201=20(car=20rep-list))=20str))=0A-=20= =20=20=20=20=20(setq=20rep-list=20(cdr=20rep-list))))=0A-=20=20str)=0A+=20= =20(unless=20(and=20(eq=20(nth=201=20math--read-preprocess-re-cache)=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= math-read-replacement-list)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(eq=20(nth=202=20math--read-preprocess-re-cache)=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20math-read-superscripts)=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(eq=20(nth=203=20= math--read-preprocess-re-cache)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20math-read-subscripts))=0A+=20=20=20=20;;=20Cache=20= invalid,=20recompute.=0A+=20=20=20=20(setq=20= math--read-preprocess-re-cache=0A+=20=20=20=20=20=20=20=20=20=20(list=20= (rx-to-string=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20`(or=20= (group=20(in=20,math-read-superscripts))=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(group=20(in=20= ,math-read-subscripts))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(group=20(or=20,@(mapcar=20#'car=20= math-read-replacement-list))))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20t)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= math-read-replacement-list=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20math-read-superscripts=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20math-read-subscripts)))=0A+=20=20(replace-regexp-in-string=0A+=20=20=20= (nth=200=20math--read-preprocess-re-cache)=0A+=20=20=20(lambda=20(s)=0A+=20= =20=20=20=20(let=20((r=20(cadr=20(assoc=20s=20= math-read-replacement-list))))=0A+=20=20=20=20=20=20=20(cond=20= ((match-beginning=201)=20(concat=20"^("=20r=20")"))=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20((match-beginning=202)=20(concat=20"_("=20r=20")"))=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20(t=20r))))=0A+=20=20=20str=20t))=0A= =20=0A=20;;=20The=20next=20few=20variables=20are=20local=20to=20= math-read-exprs=20(and=20math-read-expr=0A=20;;=20in=20calc-ext.el),=20= but=20are=20set=20in=20functions=20they=20call.=0A= --Apple-Mail=_BB5A896F-CC0D-4C80-BF01-B61DBAA77C7D-- From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Raffael Stocker Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 02 Dec 2023 19:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: Eli Zaretskii , Stefan Monnier , 67536@debbugs.gnu.org Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.170154608123276 (code B ref 67536); Sat, 02 Dec 2023 19:42:01 +0000 Received: (at 67536) by debbugs.gnu.org; 2 Dec 2023 19:41:21 +0000 Received: from localhost ([127.0.0.1]:58678 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9Vrd-00063M-BH for submit@debbugs.gnu.org; Sat, 02 Dec 2023 14:41:21 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:33303) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9VrY-000639-0S for 67536@debbugs.gnu.org; Sat, 02 Dec 2023 14:41:19 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4SjKzh2MXHz1qsNv; Sat, 2 Dec 2023 20:41:04 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 4SjKzh0hH8z1qqlW; Sat, 2 Dec 2023 20:41:04 +0100 (CET) X-Virus-Scanned: amavis at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavis, port 10024) with ESMTP id DpubJNUUH6oe; Sat, 2 Dec 2023 20:41:03 +0100 (CET) X-Auth-Info: TmNPuDlXON3oAaRyE2wdvHwbMGHHm66io/XwMP3lUplAyJgusyAP9WQish/N1Llw Received: from Whiteflame (ppp-212-114-182-140.dynamic.mnet-online.de [212.114.182.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sat, 2 Dec 2023 20:41:03 +0100 (CET) References: <83h6l367zx.fsf@gnu.org> <83jzpzaw9s.fsf@gnu.org> <834jh1aj1d.fsf@gnu.org> <83lead81zq.fsf@gnu.org> User-agent: mu4e 1.10.8; emacs 29.1 From: Raffael Stocker Date: Sat, 02 Dec 2023 20:26:58 +0100 In-reply-to: Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Mattias Engdeg=C3=A5rd writes: > There are minor points that could be addressed: `mapc` is often better > replaced with `dolist`; Is this the case? As =E2=80=98mapc=E2=80=99 is implemented directly in C an= d =E2=80=98dolist=E2=80=99 falls back to =E2=80=98while=E2=80=99, I thought it would be the other way = around. But of course I never compared them. > the first position of a buffer is 1, not 0; Yes, I could have done that one better. I was to lazy to check... > and perhaps iterating through all elements of math-read-replacement-list = isn't ideal. > Here's a variant which computes a single regexp to do the job and should = cons a bit less. I thought about the possibility of doing this, but I didn't want to open that can of worms. Not iterating definitely sounds right, though. However, I checked your proposed version and there is an issue with replacement of sub- and superscripts. Here are a few test strings I used on my version, with the comparison strings supplied by the original: --8<---------------cut here---------------start------------->8--- (string=3D (math-read-preprocess-string "=C2=B1=E2=81=B7=E2=81=BD=E2=81=BD= =E2=81=BD=E2=81=BD=E2=82=84=E2=82=84ds=E2=82=87=E2=85=9F=E2=85=9Fl=E2=85=9B= =E2=85=9B=C2=B53=C2=BE=E2=81=B6=E2=81=B4=E2=82=8D=E2=88=9E=E2=89=A4") "+/-^(7(((()_(44)ds_(7)1:1:l(1:8)(1:8)=CE=BC3(3:4)^(64)_(()inf<=3D= ") (string=3D (math-read-preprocess-string "dsfjlsajflk klfsld flsd fkls fkl j= fjls") "dsfjlsajflk klfsld flsd fkls fkl jfjls") (string=3D (math-read-preprocess-string "") "") --8<---------------cut here---------------end--------------->8--- The last two tests work fine (as there are no replacements), but for the first, your function produces this incorrect result: "+/-^(7)^(()^(()^(()^(()_(4)_(4)ds_(7)1:1:l(1:8)(1:8)=CE=BC3(3:4)^(6)^(4)_(= ()inf<=3D" > Raffael, maybe you could see if this makes a difference in Org table perf= ormance. I'm looking forward to doing so. Regards, Raffael From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Dec 2023 10:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Raffael Stocker Cc: Eli Zaretskii , Stefan Monnier , 67536@debbugs.gnu.org Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.17016002074417 (code B ref 67536); Sun, 03 Dec 2023 10:44:02 +0000 Received: (at 67536) by debbugs.gnu.org; 3 Dec 2023 10:43:27 +0000 Received: from localhost ([127.0.0.1]:59168 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9jwd-00019B-EI for submit@debbugs.gnu.org; Sun, 03 Dec 2023 05:43:27 -0500 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]:50312) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9jwa-00018t-TH for 67536@debbugs.gnu.org; Sun, 03 Dec 2023 05:43:25 -0500 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-50bc22c836bso4862190e87.0 for <67536@debbugs.gnu.org>; Sun, 03 Dec 2023 02:43:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701600189; x=1702204989; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:from:to:cc:subject :date:message-id:reply-to; bh=NrrxzVfDZzRY4hU1hAw3qELMknBYoz5+gbm41HDSdwg=; b=d/9ZbzgZUDiOAywvegFzJ5zIgjEnslUWUZM/WvcxgRu1+f75k6xliwQk3vtDMyj4Y+ U8AuvYTZivWgBXTIjfSZ4WusmDP+XZV+s1AHaDlCtdw2kxQyDBOp/e6V7suUp8MtZygT GFWdR4WCoGuOR1jOjPIhAcnBObccmfwbfQ5Z0+MLVlPTSNY6RHLFAIbp6C0HOad7BkFe J5zBS4r8ClqMRezxmDXGznCtCxoa1q/U+eOqLaT7JNjlN8QgR+sh6QKeIjBsIFf9rdyG HXIP1me3sITN2zNutTdH4LoaBf2C1C9tvuhFF7/+5kMVpBrfrhhqD/XWLVgLs5/lVeZW LHUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701600189; x=1702204989; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=NrrxzVfDZzRY4hU1hAw3qELMknBYoz5+gbm41HDSdwg=; b=cm9rTs7IBGeAp2UUOI8zc80h1xnBy6jfTetJLws2rsxP5AHWrkJkBVlnTBp7pdN+qm USDpfUSlcjiUDQtmGThUdtWyK6wkOCkh9X6qInjGuPqULGzRtAJcDmDjkiTWg/zy7tho mmh2/OWJJhu50JxX3eWV/teetR4yYDnCGBa2ue3+CSA4U0Qdloclq+TQPQyL+ZPaet5R q30Q9Q5elAXKzg3VlvJTdLg748Z3Ec9+93xTSiBosdjOPcnqjXl/QsR2qHx6u2JgXqD4 jwKlZhvCT6AJpkO6ZnJ+d5/gZRzd+opeqXjtwKk6QoZ8/8F/OxGvut3Ymdeg4U1rro2j QQaA== X-Gm-Message-State: AOJu0Yyf8wMKRz84nh+VG3+OIjUiAGvXp8asem7kjjg/dXN4rKeSInGV KR9qwsT7AKmc8HAZEE3O6CI= X-Google-Smtp-Source: AGHT+IGAbhmt/qFY6o5sl6TeAE1sPBjm+IRJuh+YGTqfMZKPAYwsYySR3fK+7Tjxu/9V8ZjIoRbIlg== X-Received: by 2002:a19:644e:0:b0:50b:f18f:7b22 with SMTP id b14-20020a19644e000000b0050bf18f7b22mr313570lfj.35.1701600188918; Sun, 03 Dec 2023 02:43:08 -0800 (PST) Received: from smtpclient.apple (c188-150-165-235.bredband.tele2.se. [188.150.165.235]) by smtp.gmail.com with ESMTPSA id y12-20020a19914c000000b0050bf1c67922sm169306lfj.79.2023.12.03.02.43.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Dec 2023 02:43:08 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= In-Reply-To: Date: Sun, 3 Dec 2023 11:43:07 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <1B1320A5-9FE9-4747-8A07-6F7FF71E8840@gmail.com> References: <83h6l367zx.fsf@gnu.org> <83jzpzaw9s.fsf@gnu.org> <834jh1aj1d.fsf@gnu.org> <83lead81zq.fsf@gnu.org> X-Mailer: Apple Mail (2.3654.120.0.1.15) X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 2 dec. 2023 kl. 20.26 skrev Raffael Stocker : > Is this the case? As =E2=80=98mapc=E2=80=99 is implemented directly in = C and =E2=80=98dolist=E2=80=99 > falls back to =E2=80=98while=E2=80=99, I thought it would be the other = way around. It's the function calls that are expensive. `dolist` just expands to a = loop. It's even worse if the lambda expression accesses variables outside = (which wasn't the case here) because that forces creation of a closure. > However, I checked your proposed version and there is an issue with > replacement of sub- and superscripts. Look at that, I got the semantics wrong. Sorry about that. Here's a new = patch. A lot less pretty this time. In any case, make sure to include unit tests in your final patch. The whole problem is compounded by the public variables = (math-read-replacement-list etc) that we somehow feel a need to keep = unchanged just in case some user modifies them, despite this almost = certainly never happens. From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Raffael Stocker Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Dec 2023 11:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: Eli Zaretskii , Stefan Monnier , 67536@debbugs.gnu.org Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.17016020878312 (code B ref 67536); Sun, 03 Dec 2023 11:15:01 +0000 Received: (at 67536) by debbugs.gnu.org; 3 Dec 2023 11:14:47 +0000 Received: from localhost ([127.0.0.1]:59187 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9kQx-0002A0-F3 for submit@debbugs.gnu.org; Sun, 03 Dec 2023 06:14:47 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:41723) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9kQv-00029m-Jy for 67536@debbugs.gnu.org; Sun, 03 Dec 2023 06:14:46 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Sjkhm3RCtz1qsP9; Sun, 3 Dec 2023 12:14:32 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 4Sjkhm20yxz1qqlS; Sun, 3 Dec 2023 12:14:32 +0100 (CET) X-Virus-Scanned: amavis at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavis, port 10024) with ESMTP id rwjDT9zYRZW8; Sun, 3 Dec 2023 12:14:31 +0100 (CET) X-Auth-Info: UUZLSPDx2xZva4vy1wBBsIf/Wp+QDTd5Tfdc2SAx+eLEcpuYNyH/ZivDgcwzvp1q Received: from Whiteflame (ppp-212-114-182-140.dynamic.mnet-online.de [212.114.182.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sun, 3 Dec 2023 12:14:31 +0100 (CET) References: <83h6l367zx.fsf@gnu.org> <83jzpzaw9s.fsf@gnu.org> <834jh1aj1d.fsf@gnu.org> <83lead81zq.fsf@gnu.org> <1B1320A5-9FE9-4747-8A07-6F7FF71E8840@gmail.com> User-agent: mu4e 1.10.8; emacs 29.1 From: Raffael Stocker Date: Sun, 03 Dec 2023 12:13:39 +0100 In-reply-to: <1B1320A5-9FE9-4747-8A07-6F7FF71E8840@gmail.com> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Mattias Engdeg=C3=A5rd writes: > Look at that, I got the semantics wrong. Sorry about that. Here's a new p= atch. Is it possible you forgot the attachment? From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Dec 2023 11:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Raffael Stocker Cc: Eli Zaretskii , Stefan Monnier , 67536@debbugs.gnu.org Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.170160473713795 (code B ref 67536); Sun, 03 Dec 2023 11:59:02 +0000 Received: (at 67536) by debbugs.gnu.org; 3 Dec 2023 11:58:57 +0000 Received: from localhost ([127.0.0.1]:59208 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9l7f-0003aP-0n for submit@debbugs.gnu.org; Sun, 03 Dec 2023 06:58:56 -0500 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]:58461) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9l7Z-0003a7-1r for 67536@debbugs.gnu.org; Sun, 03 Dec 2023 06:58:53 -0500 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-50bce78f145so4224263e87.0 for <67536@debbugs.gnu.org>; Sun, 03 Dec 2023 03:58:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701604713; x=1702209513; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:from:to:cc:subject:date:message-id:reply-to; bh=D+LAvI+sUFH4I3e3cB2V5ivhixcEp89lF4tW84ZWmME=; b=KzweuNW6ElFZhm4McF/4RkDAosQ9gOnVjUPDcfQCiSb5zRUIsrNErXjPN7j/vEzNng v08TFHtGNQ70QBWRsa8gKgzRb9EHGv1Vqr806b1ZN48seEQFesEDLBnzOU6ADGF0ECqF BYxQCQIFXU301lJZQ9BLBjrNNJO+jtQUeKYJSdL1PsiG8GXEL1ovUj6Cb29mYpMWuhTS 3BJzD1Y4IUP7BNvglF8jmcParmIzLy+GGugZRQuo/vq5nPnV+8JK1ldlfTFnIsiDyiFb CoR4kQyNiFR4sOPnOIkcBmh/0zpfaUiB1/epdOVugkajyQfEbd+WSbSXsrLaQoSBLSea XxdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701604713; x=1702209513; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=D+LAvI+sUFH4I3e3cB2V5ivhixcEp89lF4tW84ZWmME=; b=RqvYKmA3yL0OOEEFoDITWrHiCQJ8nW3LeDcSKKD+lyQgE013zIAwTDit90Bfz5zVwj iQWQjMYvmX9HiK0NHTa1ZbTSLiOpxhpqJ1pBkpbwaEjKhF1pBt+rRY/uK7/YXOlm/vOW 9Pr+KBLLxFBeeALZdSSAm2AL8bAUE8h8hO/i8Sx1g3C+Zdh286XDY8iKz2PoFhboSsOF iA/7ni5+kLeE7T9PYU44dcb/kDwsru6UrfQVgk6lS5/pJ8eqSBKy7A7H4tZtdX9IchfA 9kNhGll7vhQ1WpFEcwi9BZ0+PJ0PQlNF511jpRvSOgWj0cZK24bWDZ500tPYMShOiTmQ QVEw== X-Gm-Message-State: AOJu0YyvQuFDehovLRjlWviqVa1J8vB+bWguk57wAHO45dxO5y7wPuC4 0PfhyiJLH3ofOMRZBF9CHKk= X-Google-Smtp-Source: AGHT+IE/ap6K67OVm7Y1WilKGXuJWCKAK3cgkTGG8h0oOr+FzHS+HnuN9GT1JHDK68EE4LqnW3i0MQ== X-Received: by 2002:ac2:5dfc:0:b0:50b:d764:8e5c with SMTP id z28-20020ac25dfc000000b0050bd7648e5cmr976712lfq.110.1701604712689; Sun, 03 Dec 2023 03:58:32 -0800 (PST) Received: from smtpclient.apple (c188-150-165-235.bredband.tele2.se. [188.150.165.235]) by smtp.gmail.com with ESMTPSA id w14-20020a0565120b0e00b004ff725d1a27sm142989lfu.234.2023.12.03.03.58.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Dec 2023 03:58:32 -0800 (PST) From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Message-Id: Content-Type: multipart/mixed; boundary="Apple-Mail=_2CF78ABD-DA77-4CC3-8273-827AA4E16BBB" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Date: Sun, 3 Dec 2023 12:58:31 +0100 In-Reply-To: References: <83h6l367zx.fsf@gnu.org> <83jzpzaw9s.fsf@gnu.org> <834jh1aj1d.fsf@gnu.org> <83lead81zq.fsf@gnu.org> <1B1320A5-9FE9-4747-8A07-6F7FF71E8840@gmail.com> X-Mailer: Apple Mail (2.3654.120.0.1.15) X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_2CF78ABD-DA77-4CC3-8273-827AA4E16BBB Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii > Is it possible you forgot the attachment? How dare you suggest such a thing! --Apple-Mail=_2CF78ABD-DA77-4CC3-8273-827AA4E16BBB Content-Disposition: attachment; filename=math-read-preprocess-string.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="math-read-preprocess-string.diff" Content-Transfer-Encoding: quoted-printable diff=20--git=20a/lisp/calc/calc-aent.el=20b/lisp/calc/calc-aent.el=0A= index=2066ede3295ae..131f31afff7=20100644=0A---=20= a/lisp/calc/calc-aent.el=0A+++=20b/lisp/calc/calc-aent.el=0A@@=20-547,22=20= +547,39=20@@=20math-read-subscripts=0A=20=20=20= "=E2=82=80=E2=82=81=E2=82=82=E2=82=83=E2=82=84=E2=82=85=E2=82=86=E2=82=87=E2= =82=88=E2=82=89=E2=82=8A=E2=82=8B=E2=82=8D=E2=82=8E"=20;=20= 0123456789+-()=0A=20=20=20"A=20string=20consisting=20of=20the=20= subscripts=20allowed=20by=20Calc.")=0A=20=0A+(defvar=20= math--read-preprocess-re-cache=20nil=0A+=20=20"Cached=20regexp=20and=20= tag:=20(REGEXP=20REPLACEMENTS=20SUPERSCRIPTS=20SUBSCRIPTS)")=0A+=0A=20= ;;;###autoload=0A=20(defun=20math-read-preprocess-string=20(str)=0A=20=20= =20"Replace=20some=20substrings=20of=20STR=20by=20Calc=20equivalents."=0A= -=20=20(setq=20str=0A-=20=20=20=20=20=20=20=20(replace-regexp-in-string=20= (concat=20"["=20math-read-superscripts=20"]+")=0A-=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20"^(\\&)"=20str))=0A-=20=20(setq=20str=0A-=20=20=20=20=20=20=20=20= (replace-regexp-in-string=20(concat=20"["=20math-read-subscripts=20"]+")=0A= -=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20"_(\\&)"=20str))=0A-=20=20(let=20= ((rep-list=20math-read-replacement-list))=0A-=20=20=20=20(while=20= rep-list=0A-=20=20=20=20=20=20(setq=20str=0A-=20=20=20=20=20=20=20=20=20=20= =20=20(replace-regexp-in-string=20(nth=200=20(car=20rep-list))=0A-=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(nth=201=20(car=20rep-list))=20str))=0A-=20= =20=20=20=20=20(setq=20rep-list=20(cdr=20rep-list))))=0A-=20=20str)=0A+=20= =20(unless=20(and=20(eq=20(nth=201=20math--read-preprocess-re-cache)=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= math-read-replacement-list)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(eq=20(nth=202=20math--read-preprocess-re-cache)=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20math-read-superscripts)=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(eq=20(nth=203=20= math--read-preprocess-re-cache)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20math-read-subscripts))=0A+=20=20=20=20;;=20Cache=20= invalid,=20recompute.=0A+=20=20=20=20(setq=20= math--read-preprocess-re-cache=0A+=20=20=20=20=20=20=20=20=20=20(list=20= (rx-to-string=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20`(or=20= (group=20(+=20(in=20,math-read-superscripts)))=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(group=20(+=20(in=20= ,math-read-subscripts)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(group=20(or=20,@(mapcar=20#'car=20= math-read-replacement-list))))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20t)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= math-read-replacement-list=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20math-read-superscripts=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20math-read-subscripts)))=0A+=20=20(replace-regexp-in-string=0A+=20=20=20= (nth=200=20math--read-preprocess-re-cache)=0A+=20=20=20(lambda=20(s)=0A+=20= =20=20=20=20(let=20((r=20(mapconcat=20(lambda=20(c)=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(cadr=20= (assoc=20(char-to-string=20c)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20math-read-replacement-list)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20s)))=0A+=20=20=20=20=20=20=20(cond=20= ((match-beginning=201)=20(concat=20"^("=20r=20")"))=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20((match-beginning=202)=20(concat=20"_("=20r=20")"))=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20(t=20r))))=0A+=20=20=20str=20t))=0A= =20=0A=20;;=20The=20next=20few=20variables=20are=20local=20to=20= math-read-exprs=20(and=20math-read-expr=0A=20;;=20in=20calc-ext.el),=20= but=20are=20set=20in=20functions=20they=20call.=0A= --Apple-Mail=_2CF78ABD-DA77-4CC3-8273-827AA4E16BBB-- From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Raffael Stocker Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Dec 2023 19:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: Eli Zaretskii , Stefan Monnier , 67536@debbugs.gnu.org Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.170180457118698 (code B ref 67536); Tue, 05 Dec 2023 19:30:02 +0000 Received: (at 67536) by debbugs.gnu.org; 5 Dec 2023 19:29:31 +0000 Received: from localhost ([127.0.0.1]:38387 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAb6m-0004rT-Ep for submit@debbugs.gnu.org; Tue, 05 Dec 2023 14:29:31 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:49305) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAb6h-0004rG-DB for 67536@debbugs.gnu.org; Tue, 05 Dec 2023 14:29:27 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Sl9ZY4WHrz1qsPG; Tue, 5 Dec 2023 20:29:09 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 4Sl9ZY2c0Kz1qqlS; Tue, 5 Dec 2023 20:29:09 +0100 (CET) X-Virus-Scanned: amavis at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavis, port 10024) with ESMTP id KhUh3sTQeslL; Tue, 5 Dec 2023 20:29:05 +0100 (CET) X-Auth-Info: ln/a/FSe4zjor0TzI+CQ+8wxi+47cZvDeMLjI8Eay8FcMjRzIJ9Fq8K3v46sr8RJ Received: from Whiteflame (ppp-212-114-182-26.dynamic.mnet-online.de [212.114.182.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 5 Dec 2023 20:29:05 +0100 (CET) References: <83h6l367zx.fsf@gnu.org> <83jzpzaw9s.fsf@gnu.org> <834jh1aj1d.fsf@gnu.org> <83lead81zq.fsf@gnu.org> <1B1320A5-9FE9-4747-8A07-6F7FF71E8840@gmail.com> User-agent: mu4e 1.10.8; emacs 29.1 From: Raffael Stocker Date: Tue, 05 Dec 2023 19:14:36 +0100 In-reply-to: <1B1320A5-9FE9-4747-8A07-6F7FF71E8840@gmail.com> Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 2.9 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= writes: > Here's a new patch. > A lot less pretty this time. > > In any case, make sure to include unit tests in your final patch. Ok, here it comes. Content analysis details: (2.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [212.18.0.9 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [212.18.0.9 listed in wl.mailspike.net] 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [212.114.182.26 listed in zen.spamhaus.org] 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.9 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= writes: > Here's a new patch. > A lot less pretty this time. > > In any case, make sure to include unit tests in your final patch. Ok, here it comes. Content analysis details: (1.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [212.18.0.9 listed in list.dnswl.org] 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [212.114.182.26 listed in zen.spamhaus.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [212.18.0.9 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 T_SCC_BODY_TEXT_LINE No description available. -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mattias Engdeg=C3=A5rd writes: > Here's a new patch. > A lot less pretty this time. > > In any case, make sure to include unit tests in your final patch. Ok, here it comes. I have constructed two org tables for the test (see test-input.org) that are reasonably long and contain a few not too unreasonable formulas. The nature of the formulas is not too important for the tests, I just took them from my original "offending" table. I also added unit tests for the function, as requested. One of the tables has no special characters, so =E2=80=98math-read-preprocess-string=E2=80=99 just has to walk through with= out doing any real work (arguably the most common case). The other table is full of replaceable stuff. I used these two tables to compare the original with the new version of =E2=80=98math-read-preprocess-string=E2=80=99. The resu= lts are in test-results.org. As before, I compared =E2=80=98gcs-done=E2=80=99 and =E2=80=98gc-elapsed=E2= =80=99 (with standard settings for =E2=80=98gc-cons-threshold=E2=80=99 and =E2=80=98gc-cons-perce= ntage=E2=80=99) with both versions and tables. I also instrumented =E2=80=98org-table-recalculate=E2= =80=99 and =E2=80=98math-read-preprocess-string=E2=80=99 using elp. Then I set =E2=80= =98gc-cons-threshold=E2=80=99 to a large value and ran the same tests again. For the latter test, I only report =E2=80=98elp-results=E2=80=99 (as no GC was triggered). I recalculated every table three times per reported elp result, as it takes three evaluations for the calculation to converge. Some interesting results are: - time spent in GC reduces from 2.11 s to 0.78 s for the second table (with replacements) - elp report of average time decreases from 4.6316224e-3 s to 3.0294569e-4 s for the second table - with GC prevented, elp reports avg. time 3.4286452e-4 s vs. 4.9444e-5 s - elp report of elapsed time for =E2=80=98org-table-recalculate=E2=80=99 fo= r three evaluations (what the user sees) decreases from 8.36 s to 4.11 s (with standard GC settings again) This is a real win especially for large tables. Needless to say, I am very excited about this optimization. (Just for completeness, I quickly compared my version to Mattias' version, the latter is about a factor of two faster according to elp.) Regards, Raffael --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-lisp-calc-calc-aent.el-math-read-preprocess-string-o.patch Content-Transfer-Encoding: quoted-printable Content-Description: math-read-preprocess-string patch >From c5bd32ef197d2236928d2d6764bfcab5cef0ea6d Mon Sep 17 00:00:00 2001 From: Raffael Stocker Date: Tue, 5 Dec 2023 20:06:36 +0100 Subject: [PATCH] * lisp/calc/calc-aent.el (math-read-preprocess-string): optimize (bug#67536) MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit This is an optimized version of =E2=80=98math-read-preprocess-string=E2=80= =99 by Mattias Engdeg=C3=A5rd , with unit tests. This function is called by calc-eval, which in turn is called repeatedly when re-calculating org-mode tables. It was one of the main bottlenecks there and this optimization addresses this by not repeatedly allocating new strings while iterating through the replacement list, but instead working through the argument string only once, using a "flattened" and cached regexp and only one call to =E2=80=98replace-regexp-in-string=E2=80=99. --- lisp/calc/calc-aent.el | 43 +++++++++++++++++++++++++----------- test/lisp/calc/calc-tests.el | 27 ++++++++++++++++++++++ 2 files changed, 57 insertions(+), 13 deletions(-) diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el index 66ede3295ae..131f31afff7 100644 --- a/lisp/calc/calc-aent.el +++ b/lisp/calc/calc-aent.el @@ -547,22 +547,39 @@ math-read-subscripts "=E2=82=80=E2=82=81=E2=82=82=E2=82=83=E2=82=84=E2=82=85=E2=82=86=E2=82= =87=E2=82=88=E2=82=89=E2=82=8A=E2=82=8B=E2=82=8D=E2=82=8E" ; 0123456789+-() "A string consisting of the subscripts allowed by Calc.") =20 +(defvar math--read-preprocess-re-cache nil + "Cached regexp and tag: (REGEXP REPLACEMENTS SUPERSCRIPTS SUBSCRIPTS)") + ;;;###autoload (defun math-read-preprocess-string (str) "Replace some substrings of STR by Calc equivalents." - (setq str - (replace-regexp-in-string (concat "[" math-read-superscripts "]+") - "^(\\&)" str)) - (setq str - (replace-regexp-in-string (concat "[" math-read-subscripts "]+") - "_(\\&)" str)) - (let ((rep-list math-read-replacement-list)) - (while rep-list - (setq str - (replace-regexp-in-string (nth 0 (car rep-list)) - (nth 1 (car rep-list)) str)) - (setq rep-list (cdr rep-list)))) - str) + (unless (and (eq (nth 1 math--read-preprocess-re-cache) + math-read-replacement-list) + (eq (nth 2 math--read-preprocess-re-cache) + math-read-superscripts) + (eq (nth 3 math--read-preprocess-re-cache) + math-read-subscripts)) + ;; Cache invalid, recompute. + (setq math--read-preprocess-re-cache + (list (rx-to-string + `(or (group (+ (in ,math-read-superscripts))) + (group (+ (in ,math-read-subscripts))) + (group (or ,@(mapcar #'car math-read-replacement-lis= t)))) + t) + math-read-replacement-list + math-read-superscripts + math-read-subscripts))) + (replace-regexp-in-string + (nth 0 math--read-preprocess-re-cache) + (lambda (s) + (let ((r (mapconcat (lambda (c) + (cadr (assoc (char-to-string c) + math-read-replacement-list))) + s))) + (cond ((match-beginning 1) (concat "^(" r ")")) + ((match-beginning 2) (concat "_(" r ")")) + (t r)))) + str t)) =20 ;; The next few variables are local to math-read-exprs (and math-read-expr ;; in calc-ext.el), but are set in functions they call. diff --git a/test/lisp/calc/calc-tests.el b/test/lisp/calc/calc-tests.el index 5b11dd950ba..08b5f5575db 100644 --- a/test/lisp/calc/calc-tests.el +++ b/test/lisp/calc/calc-tests.el @@ -816,5 +816,32 @@ calc-nth-root (x (calc-tests--calc-to-number (math-pow 8 '(frac 1 6))))) (should (< (abs (- x (sqrt 2.0))) 1.0e-10)))) =20 +(ert-deftest calc-math-read-preprocess-string () + "Test replacement of allowed special Unicode symbols." + ;; ... doesn't change an empty string + (should (string=3D "" (math-read-preprocess-string ""))) + ;; ... doesn't change a string without characters from + ;; =E2=80=98math-read-replacement-list=E2=80=99 + (let ((str "don't replace here")) + (should (string=3D str (math-read-preprocess-string str)))) + ;; ... replaces irrespective of position in input string + (should (string=3D "^(1)" (math-read-preprocess-string "=C2=B9"))) + (should (string=3D "some^(1)" (math-read-preprocess-string "some=C2=B9")= )) + (should (string=3D "^(1)time" (math-read-preprocess-string "=C2=B9time")= )) + (should (string=3D "some^(1)else" (math-read-preprocess-string "some=C2= =B9else"))) + ;; ... replaces every element of =E2=80=98math-read-replacement-list=E2= =80=99 correctly, + ;; in particular combining consecutive super-/subscripts into one + ;; exponent/subscript + (should (string=3D (concat "+/-*:-/*inf<=3D>=3D<=3D>=3D=CE=BC(1:4)(1:2)(= 3:4)(1:3)(2:3)" + "(1:5)(2:5)(3:5)(4:5)(1:6)(5:6)" + "(1:8)(3:8)(5:8)(7:8)1:^(0123456789+-()ni)" + "_(0123456789+-())") + (math-read-preprocess-string (mapconcat #'car + math-read-repla= cement-list + "")))) + ;; ... signals an error if the argument is not a string + (should-error (math-read-preprocess-string nil)) + (should-error (math-read-preprocess-string 42))) + (provide 'calc-tests) ;;; calc-tests.el ends here --=20 2.43.0 --=-=-= Content-Type: text/x-org; charset=utf-8 Content-Disposition: attachment; filename=test-input.org Content-Transfer-Encoding: quoted-printable Content-Description: test-input.org * Test functions ** GC status with default configuration To write GC status into a CSV table in buffer *calc-gc*: #+begin_src emacs-lisp :results none (defun my-gc-status (orig-fun &rest args) (let* ((done-bf gcs-done) (elapsed-bf gc-elapsed) (res (apply orig-fun args)) (done-af gcs-done) (elapsed-af gc-elapsed)) (with-current-buffer (get-buffer-create "*calc-gc*") (goto-char (point-max)) (insert (format "%d,%d,%d,%f,%f,%f\n" done-bf done-af (- done-af done-bf) elapsed-bf elapsed-af (- elapsed-af elapsed-bf))= )) res)) #+end_src advise: #+begin_src emacs-lisp :results none (advice-add 'org-table-recalculate :around #'my-gc-status) #+end_src stupefy: #+begin_src emacs-lisp :results none (advice-remove 'org-table-recalculate #'my-gc-status) #+end_src ** Instrument with ELP instrument: #+begin_src emacs-lisp :results none (elp-instrument-list '(org-table-recalculate math-read-preprocess-stri= ng)) #+end_src restore: #+begin_src emacs-lisp :results none (elp-restore-all) #+end_src ** Preventing GC For the performance comparison with elp (gcs-done difference should alwa= ys be zero): #+begin_src emacs-lisp :results none (defmacro with-gc-unlikely (&rest body) (declare (indent 0)) `(let ((gc-cons-threshold (* 200 gc-cons-threshold))) ,@body)) (defun my-gc-status (orig-fun &rest args) (with-gc-unlikely (let* ((done-bf gcs-done) (elapsed-bf gc-elapsed) (res (apply orig-fun args)) (done-af gcs-done) (elapsed-af gc-elapsed)) (with-current-buffer (get-buffer-create "*calc-gc*") (goto-char (point-max)) (insert (format "%d,%d,%d,%f,%f,%f\n" done-bf done-af (- done-af done-bf) elapsed-bf elapsed-af (- elapsed-af elapsed-bf= )))) res))) #+end_src * Table without replacements | | a | b | c | d | e | f | g | h | i | j | = k | l | |---+------+------+------+------+-----+-----+------+----+-------+------+-= -------+-----| | | 1 | 5.0 | 1.00 | 150 | 200 | | | | | | = | | | | 2 | 5.1 | 1.01 | 151 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 3 | 5.2 | 1.02 | 152 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 4 | 5.3 | 1.03 | 153 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 5 | 5.4 | 1.04 | 154 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 6 | 5.5 | 1.05 | 155 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 7 | 5.6 | 1.06 | 156 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 8 | 5.7 | 1.07 | 157 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 9 | 5.8 | 1.08 | 158 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 10 | 5.9 | 1.09 | 159 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 11 | 6.0 | 1.10 | 160 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 12 | 6.1 | 1.11 | 161 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 13 | 6.2 | 1.12 | 162 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 14 | 6.3 | 1.13 | 163 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 15 | 6.4 | 1.14 | 164 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 16 | 6.5 | 1.15 | 165 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 17 | 6.6 | 1.16 | 166 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 18 | 6.7 | 1.17 | 167 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 19 | 6.8 | 1.18 | 168 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 20 | 6.9 | 1.19 | 169 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 21 | 7.0 | 1.20 | 170 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 22 | 7.1 | 1.21 | 171 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 23 | 7.2 | 1.22 | 172 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 24 | 7.3 | 1.23 | 173 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 25 | 7.4 | 1.24 | 174 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 26 | 7.5 | 1.25 | 175 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 27 | 7.6 | 1.26 | 176 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 28 | 7.7 | 1.27 | 177 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 29 | 7.8 | 1.28 | 178 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 30 | 7.9 | 1.29 | 179 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 31 | 8.0 | 1.30 | 180 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 32 | 8.1 | 1.31 | 181 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 33 | 8.2 | 1.32 | 182 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 34 | 8.3 | 1.33 | 183 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 35 | 8.4 | 1.34 | 184 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 36 | 8.5 | 1.35 | 185 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 37 | 8.6 | 1.36 | 186 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 38 | 8.7 | 1.37 | 187 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 39 | 8.8 | 1.38 | 188 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 40 | 8.9 | 1.39 | 189 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 41 | 9.0 | 1.40 | 190 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 42 | 9.1 | 1.41 | 191 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 43 | 9.2 | 1.42 | 192 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 44 | 9.3 | 1.43 | 193 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 45 | 9.4 | 1.44 | 194 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 46 | 9.5 | 1.45 | 195 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 47 | 9.6 | 1.46 | 196 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 48 | 9.7 | 1.47 | 197 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 49 | 9.8 | 1.48 | 198 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 50 | 9.9 | 1.49 | 199 | 1 | 0.1 | 0.01 | 1 | 1.01 | 1.1 | = 2.11 | 4 | | | 1275 | 3725 | 6225 | 8725 | 49 | 4.9 | 0.49 | 49 | 49.49 | 53.9 | = 103.39 | 196 | | | | | | | 40 | 4. | 0.4 | 40 | 40.4 | 44. | = 84.4 | 208 | #+tblfm: @<<<$6..@>>>$9=3D@@#$-4-@-1$-4::@3$10..@>>>$11=3D$-4+$-2::@3$12.= .@>>>$12=3D$10+$11::@>>$6..@>>$12=3Dvsum(@<<<..@>>>)::@>$6..@>$12=3D@>>*40/= vlen(@<<<..@>>>) * Table with replacements =20=20 | | a | b | c = | d | e | f | g | = h | i | j | k | = l | |---+------------------------------------------+------+------------------= --+------+------------------------------------------+-------------+---+----= --+------------------------------------------+------------+--------------+-= ---------| | | 1=C2=B2=C2=B3 | =C2=BC | 1= =E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BE | 1.50 | 200 | |= | | | | = | | | | 2=C2=B2=C2=B3 | =C2=BD | 1= =E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BE | 1.51 | 8388607 | 1:4 |= 0 | 0.01 | 8388607 | 0.26 | 8388= 607.3 | 13:4 | | | 3=C2=B2=C2=B3 | =E2=85=9C |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.52 | 94134790219 | -1:= 8 | 0 | 0.01 | 94134790219 | -0.115 | 9413= 4790000. | 23:8 | | | 4=C2=B2=C2=B3 | =E2=85=9D |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.53 | 70274600998837 | 1:= 4 | 0 | 0.01 | 70274600998837 | 0.26 | 7.02= 74601e13 | 13:4 | | | 5=C2=B2=C2=B3 | =E2=85=9E |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.54 | 11850560210900461 | 1:= 4 | 0 | 0.01 | 11850560210900461 | 0.26 | 1.18= 50560e16 | 13:4 | | | 6=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.55 | 777809294098524691 | -3:= 4 | 0 | 0.01 | 777809294098524691 | -0.74 | 7.77= 80929e17 | 9:4 | | | 7=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.56 | 26579017117027313527 | = 0 | 0 | 0.01 | 26579017117027313527 | 0.01 | 2.65= 79017e19 | 3 | | | 8=C2=B2=C2=B3 | =C2=BC | 1= =E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BE | 1.57 | 562927063018624735369 | 1:8 |= 0 | 0.01 | 562927063018624735369 | 0.135 | 5.62927= 06e20 | 25:8 | | | 9=C2=B2=C2=B3 | =C2=BD | 1= =E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BE | 1.58 | 8272642309293795444217 | 1:4 |= 0 | 0.01 | 8272642309293795444217 | 0.26 | 8.27264= 23e21 | 13:4 | | | 10=C2=B2=C2=B3 | =E2=85=9C |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.59 | 91137061880347498904071 | -1:= 8 | 0 | 0.01 | 91137061880347498904071 | -0.115 | 9.11= 37062e22 | 23:8 | | | 11=C2=B2=C2=B3 | =E2=85=9D |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.60 | 795430243255237372246531 | 1:= 4 | 0 | 0.01 | 795430243255237372246531 | 0.26 | 7.95= 43024e23 | 13:4 | | | 12=C2=B2=C2=B3 | =E2=85=9E |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.61 | 5729307023693999638873597 | 1:= 4 | 0 | 0.01 | 5729307023693999638873597 | 0.26 | 5.72= 93070e24 | 13:4 | | | 13=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.62 | 35129168146463879355925669 | -3:= 4 | 0 | 0.01 | 35129168146463879355925669 | -0.74 | 3.51= 29168e25 | 9:4 | | | 14=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.63 | 187831787473568379115174747 | = 0 | 0 | 0.01 | 187831787473568379115174747 | 0.01 | 1.87= 83179e26 | 3 | | | 15=C2=B2=C2=B3 | =C2=BC | 1= =E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BE | 1.64 | 892688453514900676148638831 | 1:8 |= 0 | 0.01 | 892688453514900676148638831 | 0.135 | 8.92688= 45e26 | 25:8 | | | 16=C2=B2=C2=B3 | =C2=BD | 1= =E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BE | 1.65 | 3829486010739638927965637521 | 1:4 |= 0 | 0.01 | 3829486010739638927965637521 | 0.26 | 3.82948= 60e27 | 13:4 | | | 17=C2=B2=C2=B3 | =E2=85=9C |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.66 | 15015808743718002702962568817 | -1:= 8 | 0 | 0.01 | 15015808743718002702962568817 | -0.115 | 1.50= 15809e28 | 23:8 | | | 18=C2=B2=C2=B3 | =E2=85=9D |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.67 | 54380144713162404110759711119 | 1:= 4 | 0 | 0.01 | 54380144713162404110759711119 | 0.26 | 5.43= 80145e28 | 13:4 | | | 19=C2=B2=C2=B3 | =E2=85=9E |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.68 | 183481914331285799334907290427 | 1:= 4 | 0 | 0.01 | 183481914331285799334907290427 | 0.26 | 1.83= 48191e29 | 13:4 | | | 20=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.69 | 581031172054692272751773932741 | -3:= 4 | 0 | 0.01 | 581031172054692272751773932741 | -0.74 | 5.81= 03117e29 | 9:4 | | | 21=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.70 | 1737720075108218291929075869661 | = 0 | 0 | 0.01 | 1737720075108218291929075869661 | 0.01 | 1.73= 77201e30 | 3 | | | 22=C2=B2=C2=B3 | =C2=BC | 1= =E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BE | 1.71 | 4934832426904611970797152049187 | 1:8 |= 0 | 0.01 | 4934832426904611970797152049187 | 0.135 | 4.93483= 24e30 | 25:8 | | | 23=C2=B2=C2=B3 | =C2=BD | 1= =E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BE | 1.72 | 13369054697835081771628804991719 | 1:4 |= 0 | 0.01 | 13369054697835081771628804991719 | 0.26 | 1.33690= 55e31 | 13:4 | | | 24=C2=B2=C2=B3 | =E2=85=9C |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.73 | 34691856035580593151023361791257 | -1:= 8 | 0 | 0.01 | 34691856035580593151023361791257 | -0.115 | 3.46= 91856e31 | 23:8 | | | 25=C2=B2=C2=B3 | =E2=85=9D |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.74 | 86536223116591531988846458813801 | 1:= 4 | 0 | 0.01 | 86536223116591531988846458813801 | 0.26 | 8.65= 36223e31 | 13:4 | | | 26=C2=B2=C2=B3 | =E2=85=9E |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.75 | 208148597830180538087306455564951 | 1:= 4 | 0 | 0.01 | 208148597830180538087306455564951 | 0.26 | 2.08= 14860e32 | 13:4 | | | 27=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.76 | 484128023348879958510326019614707 | -3:= 4 | 0 | 0.01 | 484128023348879958510326019614707 | -0.74 | 4.84= 12802e32 | 9:4 | | | 28=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.77 | 1091519211706195535082261784467469 | = 0 | 0 | 0.01 | 1091519211706195535082261784467469 | 0.01 | 1.09= 15192e33 | 3 | | | 29=C2=B2=C2=B3 | =C2=BC | 1= =E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BE | 1.78 | 2390816337712139701886699259577237 | 1:8 |= 0 | 0.01 | 2390816337712139701886699259577237 | 0.135 | 2.39081= 63e33 | 25:8 | | | 30=C2=B2=C2=B3 | =C2=BD | 1= =E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BE | 1.79 | 5097597164950584229259181627260011 | 1:4 |= 0 | 0.01 | 5097597164950584229259181627260011 | 0.26 | 5.09759= 72e33 | 13:4 | | | 31=C2=B2=C2=B3 | =E2=85=9C |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.80 | 10598993761349280264138724244295391 | -1:= 8 | 0 | 0.01 | 10598993761349280264138724244295391 | -0.115 | 1.05= 98994e34 | 23:8 | | | 32=C2=B2=C2=B3 | =E2=85=9D |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.81 | 21525063224229340764105246389465377 | 1:= 4 | 0 | 0.01 | 21525063224229340764105246389465377 | 0.26 | 2.15= 25063e34 | 13:4 | | | 33=C2=B2=C2=B3 | =E2=85=9E |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.82 | 42760274649603301511494764029638369 | 1:= 4 | 0 | 0.01 | 42760274649603301511494764029638369 | 0.26 | 4.27= 60275e34 | 13:4 | | | 34=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.83 | 83201458704419485706598664449198367 | -3:= 4 | 0 | 0.01 | 83201458704419485706598664449198367 | -0.74 | 8.32= 01459e34 | 9:4 | | | 35=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.84 | 158760784408286602815807834041699371 | = 0 | 0 | 0.01 | 158760784408286602815807834041699371 | 0.01 | 1.58= 76078e35 | 3 | | | 36=C2=B2=C2=B3 | =C2=BC | 1= =E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BE | 1.85 | 297412932573705245606943964728832981 | 1:8 |= 0 | 0.01 | 297412932573705245606943964728832981 | 0.135 | 2.97412= 93e35 | 25:8 | | | 37=C2=B2=C2=B3 | =C2=BD | 1= =E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9= =E2=81=BE | 1.86 | 547549339963094416313749615179701197 | 1:4 |= 0 | 0.01 | 547549339963094416313749615179701197 | 0.26 | 5.47549= 34e35 | 13:4 | | | 38=C2=B2=C2=B3 | =E2=85=9C |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.87 | 991608514451644290273448360554554419 | -1:= 8 | 0 | 0.01 | 991608514451644290273448360554554419 | -0.115 | 9.91= 60851e35 | 23:8 | | | 39=C2=B2=C2=B3 | =E2=85=9D |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.88 | 1768013704441562415313865863052354647 | 1:= 4 | 0 | 0.01 | 1768013704441562415313865863052354647 | 0.26 | 1.76= 80137e36 | 13:4 | | | 40=C2=B2=C2=B3 | =E2=85=9E |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.89 | 3106029033705805621429846963330259881 | 1:= 4 | 0 | 0.01 | 3106029033705805621429846963330259881 | 0.26 | 3.10= 60290e36 | 13:4 | | | 41=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.90 | 5380469351373086882278320020632149721 | -3:= 4 | 0 | 0.01 | 5380469351373086882278320020632149721 | -0.74 | 5.38= 04694e36 | 9:4 | | | 42=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.91 | 9196583172440313947144261252213072167 | = 0 | 0 | 0.01 | 9196583172440313947144261252213072167 | 0.01 | 9.19= 65832e36 | 3 | | | 43=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.92 | 15520307789897775154042511507628315619 | = 0 | 0 | 0.01 | 15520307789897775154042511507628315619 | 0.01 | 1.55= 20308e37 | 3 | | | 44=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.93 | 25876066985093668061082244549398146077 | = 0 | 0 | 0.01 | 25876066985093668061082244549398146077 | 0.01 | 2.58= 76067e37 | 3 | | | 45=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.94 | 42644153941059927848679763042442769541 | = 0 | 0 | 0.01 | 42644153941059927848679763042442769541 | 0.01 | 4.26= 44154e37 | 3 | | | 46=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.95 | 69503605249637021781459803541531167611 | = 0 | 0 | 0.01 | 69503605249637021781459803541531167611 | 0.01 | 6.95= 03605e37 | 3 | | | 47=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.96 | 112085784774797397069918106867756478287 | = 0 | 0 | 0.01 | 112085784774797397069918106867756478287 | 0.01 | 1.12= 08578e38 | 3 | | | 48=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.97 | 178930596300122251281501674041276321969 | = 0 | 0 | 0.01 | 178930596300122251281501674041276321969 | 0.01 | 1.78= 93060e38 | 3 | | | 49=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.98 | 282873888982998391468387417871686072657 | = 0 | 0 | 0.01 | 282873888982998391468387417871686072657 | 0.01 | 2.82= 87389e38 | 3 | | | 50=C2=B2=C2=B3 | =E2=85=9B |= 1=E2=81=BD=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2=B9=E2=81=BA=C2= =B9=E2=81=BE | 1.99 | 443044564542626266505505897305435506351 | = 0 | 0 | 0.01 | 443044564542626266505505897305435506351 | 0.01 | 4.43= 04456e38 | 3 | | | 3125129969101606324488851263499533700625 | 73:4 | 6225 = | 8725 | 1192092895507812499999999999999999999999 | -1:8 | 0 | 0.4= 9 | 1192092895507812499999999999999999999999 | 0.365 | 1.1920929e39 | = 1175:8 | | | | | = | | 973137057557397959183673469387755102040 | -0.10204082 | 0 | 0.= 4 | 973137057557397959183673469387755102040 | 0.29795918 | 9.7313706e38 | = 15275:98 | #+tblfm: @<<<$6..@>>>$9=3D@@#$-4-@-1$-4::@4$10..@>>>$11=3D$-4+$-2::@4$12.= .@>>>$12=3D$10+$11::@>>$6..@>>$12=3Dvsum(@<<<..@>>>)::@>$6..@>$12=3D@>>*40/= vlen(@<<<..@>>>) --=-=-= Content-Type: text/x-org Content-Disposition: attachment; filename=test-results.org Content-Description: test-results.org * Old Version ** Standard GC settings *** Table without replacements GC status: #+NAME: old-gc-default | gcs-done (before) | gcs-done (after) | diff | gc-elapsed (before) | gc-elapsed (after)) | diff | |-------------------+------------------+------+---------------------+---------------------+----------| | 1054 | 1059 | 5 | 250.503539 | 252.134850 | 1.631311 | | 1059 | 1064 | 5 | 252.134850 | 253.747052 | 1.612202 | | 1065 | 1070 | 5 | 253.908064 | 255.376975 | 1.468911 | | 1073 | 1078 | 5 | 256.266807 | 257.903993 | 1.637186 | | 1079 | 1084 | 5 | 258.230357 | 259.607997 | 1.377640 | | 1084 | 1089 | 5 | 259.607997 | 261.243876 | 1.635879 | | 1093 | 1098 | 5 | 262.296405 | 263.931859 | 1.635454 | | 1098 | 1104 | 6 | 263.931859 | 265.753341 | 1.821483 | | 1104 | 1109 | 5 | 265.753341 | 267.341256 | 1.587915 | | 1113 | 1118 | 5 | 268.496715 | 270.139111 | 1.642396 | | 1119 | 1124 | 5 | 270.463732 | 272.096347 | 1.632615 | | 1124 | 1130 | 6 | 272.096347 | 273.892863 | 1.796516 | | 1133 | 1138 | 5 | 274.866291 | 276.498017 | 1.631726 | | 1139 | 1144 | 5 | 276.825122 | 278.438680 | 1.613558 | | 1144 | 1150 | 6 | 278.438680 | 280.193824 | 1.755144 | | 1153 | 1158 | 5 | 281.167176 | 282.808119 | 1.640944 | | 1159 | 1164 | 5 | 283.135641 | 284.769703 | 1.634062 | | 1165 | 1170 | 5 | 285.096659 | 286.539210 | 1.442551 | | 1172 | 1177 | 5 | 287.194050 | 288.831969 | 1.637918 | | 1177 | 1182 | 5 | 288.831969 | 290.465695 | 1.633726 | | 1183 | 1188 | 5 | 290.627810 | 292.188706 | 1.560895 | | 1190 | 1195 | 5 | 292.843087 | 294.480884 | 1.637797 | | 1195 | 1200 | 5 | 294.480884 | 296.120286 | 1.639402 | | 1201 | 1206 | 5 | 296.282287 | 297.834479 | 1.552192 | | 1208 | 1213 | 5 | 298.487386 | 300.129894 | 1.642508 | | 1213 | 1219 | 6 | 300.129894 | 301.934027 | 1.804133 | | 1219 | 1224 | 5 | 301.934027 | 303.557198 | 1.623171 | | 1226 | 1231 | 5 | 304.047446 | 305.685723 | 1.638277 | | 1232 | 1237 | 5 | 306.014809 | 307.648914 | 1.634105 | | 1237 | 1242 | 5 | 307.648914 | 309.279031 | 1.630117 | | min | max | avg | stddev | |---------+----------+-----------+-------------| | 1.37764 | 1.821483 | 1.6277245 | 0.092682838 | #+tblfm: $1=vmin(remote(old-gc-default,@<<$6..@>$6))::$2=vmax(remote(old-gc-default,@<<$6..@>$6))::$3=vmean(remote(old-gc-default,@<<$6..@>$6))::$4=vsdev(remote(old-gc-default,@<<$6..@>$6)) ELP results: #+NAME: old-elp-otr | Function Name | Call Count | Elapsed Time | Average Time | |-----------------------+------------+--------------+--------------| | org-table-recalculate | 3 | 6.313133362 | 2.1043777873 | | org-table-recalculate | 3 | 6.246987188 | 2.0823290626 | | org-table-recalculate | 3 | 6.6551302920 | 2.2183767640 | | org-table-recalculate | 3 | 6.674029333 | 2.2246764443 | | org-table-recalculate | 3 | 6.598810578 | 2.199603526 | | org-table-recalculate | 3 | 6.321018298 | 2.1070060993 | | org-table-recalculate | 3 | 6.441169476 | 2.147056492 | | org-table-recalculate | 3 | 6.441422936 | 2.1471409786 | | org-table-recalculate | 3 | 6.678658607 | 2.2262195356 | | org-table-recalculate | 3 | 6.678658607 | 2.2262195356 | | min | max | avg | stddev | |-----------+-----------+-----------+-------------| | 2.0823291 | 2.2262195 | 2.1683006 | 0.057259862 | #+tblfm: $1=vmin(remote(old-elp-otr,@<<$4..@>$4))::$2=vmax(remote(old-elp-otr,@<<$4..@>$4))::$3=vmean(remote(old-elp-otr,@<<$4..@>$4))::$4=vsdev(remote(old-elp-otr,@<<$4..@>$4)) | min | max | avg | stddev | |-----------+-----------+-----------+------------| | 6.2469872 | 6.6786586 | 6.5049019 | 0.17177959 | #+tblfm: $1=vmin(remote(old-elp-otr,@<<$3..@>$3))::$2=vmax(remote(old-elp-otr,@<<$3..@>$3))::$3=vmean(remote(old-elp-otr,@<<$3..@>$3))::$4=vsdev(remote(old-elp-otr,@<<$3..@>$3)) #+NAME: old-elp-mrps | Function Name | Call Count | Elapsed Time | Average Time | |-----------------------------+------------+--------------+--------------| | math-read-preprocess-string | 1071 | 3.2478232829 | 0.0030325147 | | math-read-preprocess-string | 1071 | 4.8031509200 | 0.0044847347 | | math-read-preprocess-string | 1071 | 2.9357323269 | 0.0027411132 | | math-read-preprocess-string | 1071 | 3.5837934030 | 0.0033462123 | | math-read-preprocess-string | 1071 | 2.8837118310 | 0.0026925413 | | math-read-preprocess-string | 1071 | 3.2555897690 | 0.0030397663 | | math-read-preprocess-string | 1071 | 4.2443911260 | 0.0039630169 | | math-read-preprocess-string | 1071 | 3.5876369039 | 0.0033498010 | | math-read-preprocess-string | 1071 | 2.9449534269 | 0.0027497230 | | math-read-preprocess-string | 1071 | 2.9449534269 | 0.0027497230 | | min | max | avg | stddev | |--------------+--------------+--------------+--------------| | 2.6925413e-3 | 4.4847347e-3 | 3.2149146e-3 | 5.9643835e-4 | #+tblfm: $1=vmin(remote(old-elp-mrps,@<<$4..@>$4))::$2=vmax(remote(old-elp-mrps,@<<$4..@>$4))::$3=vmean(remote(old-elp-mrps,@<<$4..@>$4))::$4=vsdev(remote(old-elp-mrps,@<<$4..@>$4)) | min | max | avg | stddev | |-----------+-----------+-----------+------------| | 2.8837118 | 4.8031509 | 3.4431736 | 0.63878545 | #+tblfm: $1=vmin(remote(old-elp-mrps,@<<$3..@>$3))::$2=vmax(remote(old-elp-mrps,@<<$3..@>$3))::$3=vmean(remote(old-elp-mrps,@<<$3..@>$3))::$4=vsdev(remote(old-elp-mrps,@<<$3..@>$3)) *** Table with replacements #+NAME: old-gc-default-rep | gcs-done (before) | gcs-done (after) | diff | gc-elapsed (before) | gc-elapsed (after)) | diff | |-------------------+------------------+------+---------------------+---------------------+----------| | 1280 | 1288 | 8 | 320.820101 | 323.266063 | 2.445962 | | 1288 | 1295 | 7 | 323.266063 | 325.216725 | 1.950662 | | 1296 | 1303 | 7 | 325.378476 | 327.348383 | 1.969907 | | 1305 | 1312 | 7 | 328.034073 | 330.261592 | 2.227520 | | 1312 | 1320 | 8 | 330.261592 | 332.362158 | 2.100566 | | 1320 | 1327 | 7 | 332.362158 | 334.321168 | 1.959009 | | 1328 | 1335 | 7 | 334.651412 | 336.492029 | 1.840617 | | 1336 | 1343 | 7 | 336.715810 | 338.702283 | 1.986473 | | 1343 | 1350 | 7 | 338.702283 | 340.473741 | 1.771458 | | 1351 | 1359 | 8 | 340.636036 | 343.044857 | 2.408820 | | 1359 | 1366 | 7 | 343.044857 | 344.975912 | 1.931055 | | 1367 | 1374 | 7 | 345.305170 | 347.026135 | 1.720965 | | 1422 | 1429 | 7 | 360.910961 | 363.195230 | 2.284269 | | 1430 | 1437 | 7 | 363.358932 | 365.613196 | 2.254264 | | 1437 | 1445 | 8 | 365.613196 | 368.061331 | 2.448135 | | 1446 | 1453 | 7 | 368.392605 | 370.633835 | 2.241230 | | 1453 | 1460 | 7 | 370.633835 | 372.695029 | 2.061194 | | 1461 | 1468 | 7 | 372.856827 | 374.823342 | 1.966515 | | 1469 | 1476 | 7 | 375.154456 | 377.442675 | 2.288219 | | 1477 | 1484 | 7 | 377.606173 | 379.756170 | 2.149997 | | 1484 | 1491 | 7 | 379.756170 | 381.722527 | 1.966357 | | 1492 | 1500 | 8 | 381.886163 | 384.337690 | 2.451527 | | 1500 | 1507 | 7 | 384.337690 | 386.335021 | 1.997332 | | 1507 | 1515 | 8 | 386.335021 | 388.471281 | 2.136260 | | 1517 | 1524 | 7 | 389.125091 | 391.294374 | 2.169283 | | 1524 | 1531 | 7 | 391.294374 | 393.257728 | 1.963355 | | 1532 | 1539 | 7 | 393.420813 | 395.501185 | 2.080372 | | 1540 | 1547 | 7 | 395.832669 | 398.100091 | 2.267421 | | 1547 | 1554 | 7 | 398.100091 | 400.232270 | 2.132180 | | 1555 | 1562 | 7 | 400.394950 | 402.530697 | 2.135748 | | min | max | avg | stddev | |----------+----------+-----------+------------| | 1.720965 | 2.451527 | 2.1102224 | 0.19575167 | #+tblfm: $1=vmin(remote(old-gc-default-rep,@<<$6..@>$6))::$2=vmax(remote(old-gc-default-rep,@<<$6..@>$6))::$3=vmean(remote(old-gc-default-rep,@<<$6..@>$6))::$4=vsdev(remote(old-gc-default-rep,@<<$6..@>$6)) ELP results: #+NAME: old-elp-otr-rep | Function Name | Call Count | Elapsed Time | Average Time | |-----------------------+------------+--------------+--------------| | org-table-recalculate | 3 | 8.386124891 | 2.7953749636 | | org-table-recalculate | 3 | 8.31112995 | 2.7703766499 | | org-table-recalculate | 3 | 7.615444065 | 2.538481355 | | org-table-recalculate | 3 | 8.047824394 | 2.6826081313 | | org-table-recalculate | 3 | 9.0429742769 | 3.0143247589 | | org-table-recalculate | 3 | 8.293004052 | 2.764334684 | | org-table-recalculate | 3 | 8.454038725 | 2.8180129083 | | org-table-recalculate | 3 | 8.598015534 | 2.866005178 | | org-table-recalculate | 3 | 8.2478522599 | 2.7492840866 | | org-table-recalculate | 3 | 8.5751938890 | 2.8583979630 | | min | max | avg | stddev | |-----------+-----------+-----------+------------| | 2.5384814 | 3.0143248 | 2.7857201 | 0.12423245 | #+tblfm: $1=vmin(remote(old-elp-otr-rep,@<<$4..@>$4))::$2=vmax(remote(old-elp-otr-rep,@<<$4..@>$4))::$3=vmean(remote(old-elp-otr-rep,@<<$4..@>$4))::$4=vsdev(remote(old-elp-otr-rep,@<<$4..@>$4)) | min | max | avg | stddev | |-----------+-----------+-----------+------------| | 7.6154441 | 9.0429743 | 8.3571602 | 0.37269735 | #+tblfm: $1=vmin(remote(old-elp-otr-rep,@<<$3..@>$3))::$2=vmax(remote(old-elp-otr-rep,@<<$3..@>$3))::$3=vmean(remote(old-elp-otr-rep,@<<$3..@>$3))::$4=vsdev(remote(old-elp-otr-rep,@<<$3..@>$3)) #+NAME: old-elp-mrps-rep | Function Name | Call Count | Elapsed Time | Average Time | |-----------------------------+------------+--------------+--------------| | math-read-preprocess-string | 1062 | 5.3424330849 | 0.0050305396 | | math-read-preprocess-string | 1062 | 5.007848726 | 0.0047154884 | | math-read-preprocess-string | 1062 | 4.3856793110 | 0.0041296415 | | math-read-preprocess-string | 1062 | 5.1801638940 | 0.0048777437 | | math-read-preprocess-string | 1062 | 5.0423656429 | 0.0047479902 | | math-read-preprocess-string | 1062 | 4.9785316350 | 0.0046878828 | | math-read-preprocess-string | 1062 | 5.0846951129 | 0.0047878485 | | math-read-preprocess-string | 1062 | 5.2302427329 | 0.0049248989 | | math-read-preprocess-string | 1062 | 4.5067303730 | 0.0042436255 | | math-read-preprocess-string | 1062 | 4.4291400419 | 0.0041705650 | | min | max | avg | stddev | |--------------+--------------+--------------+--------------| | 4.1296415e-3 | 5.0305396e-3 | 4.6316224e-3 | 3.2812072e-4 | #+tblfm: $1=vmin(remote(old-elp-mrps-rep,@<<$4..@>$4))::$2=vmax(remote(old-elp-mrps-rep,@<<$4..@>$4))::$3=vmean(remote(old-elp-mrps-rep,@<<$4..@>$4))::$4=vsdev(remote(old-elp-mrps-rep,@<<$4..@>$4)) | min | max | avg | stddev | |-----------+-----------+-----------+------------| | 4.3856793 | 5.3424331 | 4.9187831 | 0.34846421 | #+tblfm: $1=vmin(remote(old-elp-mrps-rep,@<<$3..@>$3))::$2=vmax(remote(old-elp-mrps-rep,@<<$3..@>$3))::$3=vmean(remote(old-elp-mrps-rep,@<<$3..@>$3))::$4=vsdev(remote(old-elp-mrps-rep,@<<$3..@>$3)) ** GC prevented *** Table without replacements ELP results: #+NAME: old-elp-otr-gcp | Function Name | Call Count | Elapsed Time | Average Time | |-----------------------+------------+--------------+--------------| | org-table-recalculate | 3 | 3.2403264490 | 1.0801088163 | | org-table-recalculate | 3 | 3.355133199 | 1.118377733 | | org-table-recalculate | 3 | 3.3670167070 | 1.1223389023 | | org-table-recalculate | 3 | 3.3725147580 | 1.1241715860 | | org-table-recalculate | 3 | 3.362646752 | 1.1208822506 | | org-table-recalculate | 3 | 3.341763135 | 1.1139210449 | | org-table-recalculate | 3 | 3.481111953 | 1.160370651 | | org-table-recalculate | 3 | 3.4572762 | 1.1524254 | | org-table-recalculate | 3 | 3.3516910289 | 1.117230343 | | org-table-recalculate | 3 | 3.4367006460 | 1.145566882 | | min | max | avg | stddev | |-----------+-----------+-----------+-------------| | 1.0801088 | 1.1603707 | 1.1255394 | 0.022828419 | #+tblfm: $1=vmin(remote(old-elp-otr-gcp,@<<$4..@>$4))::$2=vmax(remote(old-elp-otr-gcp,@<<$4..@>$4))::$3=vmean(remote(old-elp-otr-gcp,@<<$4..@>$4))::$4=vsdev(remote(old-elp-otr-gcp,@<<$4..@>$4)) | min | max | avg | stddev | |-----------+-----------+-----------+-------------| | 3.2403264 | 3.4811120 | 3.3766181 | 0.068485256 | #+tblfm: $1=vmin(remote(old-elp-otr-gcp,@<<$3..@>$3))::$2=vmax(remote(old-elp-otr-gcp,@<<$3..@>$3))::$3=vmean(remote(old-elp-otr-gcp,@<<$3..@>$3))::$4=vsdev(remote(old-elp-otr-gcp,@<<$3..@>$3)) #+NAME: old-elp-mrps-gcp | Function Name | Call Count | Elapsed Time | Average Time | |-----------------------------+------------+--------------+--------------| | math-read-preprocess-string | 1071 | 0.2493200720 | 0.0002327918 | | math-read-preprocess-string | 1071 | 0.2506797709 | 0.0002340614 | | math-read-preprocess-string | 1071 | 0.2526552609 | 0.0002359059 | | math-read-preprocess-string | 1071 | 0.2530469949 | 0.0002362717 | | math-read-preprocess-string | 1071 | 0.2542395049 | 0.0002373851 | | math-read-preprocess-string | 1071 | 0.2536397500 | 0.0002368251 | | math-read-preprocess-string | 1071 | 0.2555863690 | 0.0002386427 | | math-read-preprocess-string | 1071 | 0.2541568160 | 0.0002373079 | | math-read-preprocess-string | 1071 | 0.2546775069 | 0.0002377941 | | math-read-preprocess-string | 1071 | 0.255253958 | 0.0002383323 | | min | max | avg | stddev | |-------------+-------------+-------------+--------------| | 2.327918e-4 | 2.386427e-4 | 2.365318e-4 | 1.8636123e-6 | #+tblfm: $1=vmin(remote(old-elp-mrps-gcp,@<<$4..@>$4))::$2=vmax(remote(old-elp-mrps-gcp,@<<$4..@>$4))::$3=vmean(remote(old-elp-mrps-gcp,@<<$4..@>$4))::$4=vsdev(remote(old-elp-mrps-gcp,@<<$4..@>$4)) | min | max | avg | stddev | |------------+------------+------------+--------------| | 0.24932007 | 0.25558637 | 0.25332560 | 1.9959338e-3 | #+tblfm: $1=vmin(remote(old-elp-mrps-gcp,@<<$3..@>$3))::$2=vmax(remote(old-elp-mrps-gcp,@<<$3..@>$3))::$3=vmean(remote(old-elp-mrps-gcp,@<<$3..@>$3))::$4=vsdev(remote(old-elp-mrps-gcp,@<<$3..@>$3)) *** Table with replacements #+NAME: old-elp-otr-gcp-rep | Function Name | Call Count | Elapsed Time | Average Time | |-----------------------+------------+--------------+--------------| | org-table-recalculate | 3 | 4.6323348929 | 1.5441116309 | | org-table-recalculate | 3 | 4.415962572 | 1.471987524 | | org-table-recalculate | 3 | 4.452308577 | 1.484102859 | | org-table-recalculate | 3 | 4.426317972 | 1.4754393239 | | org-table-recalculate | 3 | 4.458149586 | 1.486049862 | | org-table-recalculate | 3 | 4.513410515 | 1.5044701716 | | org-table-recalculate | 3 | 4.545595521 | 1.515198507 | | org-table-recalculate | 3 | 4.575623074 | 1.5252076913 | | org-table-recalculate | 3 | 4.498293244 | 1.4994310813 | | org-table-recalculate | 3 | 4.570841693 | 1.5236138976 | | min | max | avg | stddev | |-----------+-----------+-----------+-------------| | 1.4719875 | 1.5441116 | 1.5029613 | 0.023892680 | #+tblfm: $1=vmin(remote(old-elp-otr-gcp-rep,@<<$4..@>$4))::$2=vmax(remote(old-elp-otr-gcp-rep,@<<$4..@>$4))::$3=vmean(remote(old-elp-otr-gcp-rep,@<<$4..@>$4))::$4=vsdev(remote(old-elp-otr-gcp-rep,@<<$4..@>$4)) | min | max | avg | stddev | |-----------+-----------+-----------+-------------| | 4.4159626 | 4.6323349 | 4.5088838 | 0.071678039 | #+tblfm: $1=vmin(remote(old-elp-otr-gcp-rep,@<<$3..@>$3))::$2=vmax(remote(old-elp-otr-gcp-rep,@<<$3..@>$3))::$3=vmean(remote(old-elp-otr-gcp-rep,@<<$3..@>$3))::$4=vsdev(remote(old-elp-otr-gcp-rep,@<<$3..@>$3)) #+NAME: old-elp-mrps-gcp-rep | Function Name | Call Count | Elapsed Time | Average Time | |-----------------------------+------------+--------------+--------------| | math-read-preprocess-string | 1062 | 0.3624429339 | 0.0003412833 | | math-read-preprocess-string | 1062 | 0.3620876769 | 0.0003409488 | | math-read-preprocess-string | 1062 | 0.3638540500 | 0.0003426120 | | math-read-preprocess-string | 1062 | 0.3637396369 | 0.0003425043 | | math-read-preprocess-string | 1062 | 0.3637937650 | 0.0003425553 | | math-read-preprocess-string | 1062 | 0.3643354190 | 0.0003430653 | | math-read-preprocess-string | 1062 | 0.3652952959 | 0.0003439692 | | math-read-preprocess-string | 1062 | 0.3657365130 | 0.0003443846 | | math-read-preprocess-string | 1062 | 0.3646950459 | 0.0003434039 | | math-read-preprocess-string | 1062 | 0.3652415269 | 0.0003439185 | | min | max | avg | stddev | |-------------+-------------+--------------+--------------| | 3.409488e-4 | 3.443846e-4 | 3.4286452e-4 | 1.1270640e-6 | #+tblfm: $1=vmin(remote(old-elp-mrps-gcp-rep,@<<$4..@>$4))::$2=vmax(remote(old-elp-mrps-gcp-rep,@<<$4..@>$4))::$3=vmean(remote(old-elp-mrps-gcp-rep,@<<$4..@>$4))::$4=vsdev(remote(old-elp-mrps-gcp-rep,@<<$4..@>$4)) | min | max | avg | stddev | |------------+------------+------------+--------------| | 0.36208768 | 0.36573651 | 0.36412219 | 1.1969413e-3 | #+tblfm: $1=vmin(remote(old-elp-mrps-gcp-rep,@<<$3..@>$3))::$2=vmax(remote(old-elp-mrps-gcp-rep,@<<$3..@>$3))::$3=vmean(remote(old-elp-mrps-gcp-rep,@<<$3..@>$3))::$4=vsdev(remote(old-elp-mrps-gcp-rep,@<<$3..@>$3)) * New version ** Standard GC settings *** Table without replacements #+NAME: new-gc-default | gcs-done (before) | gcs-done (after) | diff | gc-elapsed (before) | gc-elapsed (after)) | diff | |-------------------+------------------+------+---------------------+---------------------+----------| | 1762 | 1765 | 3 | 500.857333 | 501.867029 | 1.009696 | | 1765 | 1767 | 2 | 501.867029 | 502.528777 | 0.661748 | | 1768 | 1770 | 2 | 502.858457 | 503.519755 | 0.661298 | | 1772 | 1774 | 2 | 504.182249 | 504.860215 | 0.677966 | | 1774 | 1777 | 3 | 504.860215 | 505.853030 | 0.992815 | | 1778 | 1780 | 2 | 506.182351 | 506.846879 | 0.664528 | | 1782 | 1785 | 3 | 507.510026 | 508.501020 | 0.990994 | | 1785 | 1787 | 2 | 508.501020 | 509.164213 | 0.663193 | | 1788 | 1790 | 2 | 509.494431 | 510.155896 | 0.661465 | | 1792 | 1794 | 2 | 510.819410 | 511.482648 | 0.663238 | | 1794 | 1797 | 3 | 511.482648 | 512.474957 | 0.992309 | | 1797 | 1799 | 2 | 512.474957 | 513.135728 | 0.660771 | | 1801 | 1803 | 2 | 513.709183 | 514.372867 | 0.663683 | | 1803 | 1806 | 3 | 514.372867 | 515.288420 | 0.915553 | | 1806 | 1808 | 2 | 515.288420 | 515.949551 | 0.661131 | | 1810 | 1812 | 2 | 516.611724 | 517.271720 | 0.659996 | | 1813 | 1815 | 2 | 517.602450 | 518.265565 | 0.663115 | | 1815 | 1817 | 2 | 518.265565 | 518.927351 | 0.661786 | | 1819 | 1821 | 2 | 519.501519 | 520.162033 | 0.660514 | | 1822 | 1824 | 2 | 520.492218 | 521.155180 | 0.662963 | | 1826 | 1828 | 2 | 521.814697 | 522.480184 | 0.665487 | | 1829 | 1831 | 2 | 522.813010 | 523.474466 | 0.661456 | | 1832 | 1834 | 2 | 523.806391 | 524.467553 | 0.661163 | | 1835 | 1837 | 2 | 524.713867 | 525.379362 | 0.665494 | | 1839 | 1841 | 2 | 526.041673 | 526.702274 | 0.660601 | | 1841 | 1843 | 2 | 526.702274 | 527.363186 | 0.660912 | | 1844 | 1846 | 2 | 527.693024 | 528.353593 | 0.660569 | | 1848 | 1850 | 2 | 529.014078 | 529.675499 | 0.661421 | | 1851 | 1853 | 2 | 529.920856 | 530.582954 | 0.662098 | | 1853 | 1855 | 2 | 530.582954 | 531.248341 | 0.665387 | | 1858 | 1858 | 0 | 532.155097 | 532.155097 | 0.000000 | | 1861 | 1861 | 0 | 533.088355 | 533.088355 | 0.000000 | | min | max | avg | stddev | |-----+----------+------------+------------| | 0. | 1.009696 | 0.67104219 | 0.21145837 | #+tblfm: $1=vmin(remote(new-gc-default,@<<$6..@>$6))::$2=vmax(remote(new-gc-default,@<<$6..@>$6))::$3=vmean(remote(new-gc-default,@<<$6..@>$6))::$4=vsdev(remote(new-gc-default,@<<$6..@>$6)) ELP results: #+NAME: new-elp-otr | Function Name | Call Count | Elapsed Time | Average Time | |-----------------------+------------+--------------+--------------| | org-table-recalculate | 3 | 3.647963828 | 1.2159879426 | | org-table-recalculate | 3 | 3.650498402 | 1.2168328006 | | org-table-recalculate | 3 | 3.631013093 | 1.2103376976 | | org-table-recalculate | 3 | 3.630224191 | 1.2100747303 | | org-table-recalculate | 3 | 3.564292429 | 1.1880974763 | | org-table-recalculate | 3 | 3.308181369 | 1.102727123 | | org-table-recalculate | 3 | 3.3063494049 | 1.1021164683 | | org-table-recalculate | 3 | 3.3000922879 | 1.1000307626 | | org-table-recalculate | 3 | 3.297214875 | 1.0990716249 | | org-table-recalculate | 3 | 3.301936163 | 1.1006453876 | | min | max | avg | stddev | |-----------+-----------+-----------+-------------| | 1.0990716 | 1.2168328 | 1.1545922 | 0.057120960 | #+tblfm: $1=vmin(remote(new-elp-otr,@<<$4..@>$4))::$2=vmax(remote(new-elp-otr,@<<$4..@>$4))::$3=vmean(remote(new-elp-otr,@<<$4..@>$4))::$4=vsdev(remote(new-elp-otr,@<<$4..@>$4)) | min | max | avg | stddev | |-----------+-----------+-----------+------------| | 3.2972149 | 3.6504984 | 3.4637766 | 0.17136288 | #+tblfm: $1=vmin(remote(new-elp-otr,@<<$3..@>$3))::$2=vmax(remote(new-elp-otr,@<<$3..@>$3))::$3=vmean(remote(new-elp-otr,@<<$3..@>$3))::$4=vsdev(remote(new-elp-otr,@<<$3..@>$3)) #+NAME: new-elp-mrps | Function Name | Call Count | Elapsed Time | Average Time | |-----------------------------+------------+--------------+--------------| | math-read-preprocess-string | 1071 | 0.0359088070 | 3.352e-05 | | math-read-preprocess-string | 1071 | 0.3684005519 | 0.0003439781 | | math-read-preprocess-string | 1071 | 0.3658023279 | 0.0003415521 | | math-read-preprocess-string | 1071 | 0.0354963120 | 3.314e-05 | | math-read-preprocess-string | 1071 | 0.0361226520 | 3.372e-05 | | math-read-preprocess-string | 1071 | 0.6992056110 | 0.0006528530 | | math-read-preprocess-string | 1071 | 0.0361133740 | 3.371e-05 | | math-read-preprocess-string | 1071 | 0.3664842619 | 0.0003421888 | | math-read-preprocess-string | 1071 | 0.0355913820 | 3.323e-05 | | math-read-preprocess-string | 1071 | 0.0358934579 | 3.351e-05 | | min | max | avg | stddev | |----------+------------+-------------+--------------| | 3.314e-5 | 6.52853e-4 | 1.881402e-4 | 2.1884648e-4 | #+tblfm: $1=vmin(remote(new-elp-mrps,@<<$4..@>$4))::$2=vmax(remote(new-elp-mrps,@<<$4..@>$4))::$3=vmean(remote(new-elp-mrps,@<<$4..@>$4))::$4=vsdev(remote(new-elp-mrps,@<<$4..@>$4)) | min | max | avg | stddev | |-------------+------------+------------+------------| | 0.035496312 | 0.69920561 | 0.20150187 | 0.23438169 | #+tblfm: $1=vmin(remote(new-elp-mrps,@<<$3..@>$3))::$2=vmax(remote(new-elp-mrps,@<<$3..@>$3))::$3=vmean(remote(new-elp-mrps,@<<$3..@>$3))::$4=vsdev(remote(new-elp-mrps,@<<$3..@>$3)) *** Table with replacements #+NAME: new-gc-default-rep | gcs-done (before) | gcs-done (after) | diff | gc-elapsed (before) | gc-elapsed (after)) | diff | |-------------------+------------------+------+---------------------+---------------------+----------| | 1876 | 1878 | 2 | 537.611898 | 538.275925 | 0.664028 | | 1879 | 1881 | 2 | 538.563095 | 539.228150 | 0.665055 | | 1883 | 1885 | 2 | 539.893418 | 540.562692 | 0.669274 | | 1886 | 1889 | 3 | 540.900052 | 541.897165 | 0.997113 | | 1889 | 1892 | 3 | 541.897165 | 542.896032 | 0.998867 | | 1892 | 1895 | 3 | 542.896032 | 543.886817 | 0.990785 | | 1896 | 1899 | 3 | 544.218485 | 545.211749 | 0.993265 | | 1900 | 1902 | 2 | 545.455264 | 546.119421 | 0.664157 | | 1903 | 1905 | 2 | 546.364589 | 547.031535 | 0.666946 | | 1906 | 1909 | 3 | 547.278365 | 548.272865 | 0.994500 | | 1909 | 1912 | 3 | 548.272865 | 549.274114 | 1.001249 | | 1912 | 1915 | 3 | 549.274114 | 550.262985 | 0.988871 | | 1916 | 1919 | 3 | 550.509902 | 551.511680 | 1.001778 | | 1919 | 1921 | 2 | 551.511680 | 552.180745 | 0.669065 | | 1922 | 1924 | 2 | 552.427591 | 553.094352 | 0.666761 | | 1926 | 1928 | 2 | 553.673631 | 554.342719 | 0.669088 | | 1929 | 1932 | 3 | 554.678384 | 555.680999 | 1.002615 | | 1932 | 1935 | 3 | 555.680999 | 556.685500 | 1.004501 | | 1936 | 1939 | 3 | 557.019569 | 558.012522 | 0.992953 | | 1939 | 1941 | 2 | 558.012522 | 558.676676 | 0.664154 | | 1942 | 1944 | 2 | 558.932476 | 559.596460 | 0.663984 | | 1946 | 1948 | 2 | 560.173468 | 560.840249 | 0.666782 | | 1949 | 1951 | 2 | 561.105505 | 561.773733 | 0.668227 | | 1952 | 1954 | 2 | 562.020766 | 562.689543 | 0.668777 | | 1955 | 1958 | 3 | 563.022710 | 564.024487 | 1.001777 | | 1958 | 1961 | 3 | 564.024487 | 565.028165 | 1.003678 | | 1961 | 1964 | 3 | 565.028165 | 566.023460 | 0.995295 | | 1965 | 1968 | 3 | 566.352768 | 567.351071 | 0.998304 | | 1968 | 1970 | 2 | 567.351071 | 568.015533 | 0.664461 | | 1971 | 1973 | 2 | 568.260103 | 568.922794 | 0.662691 | | 1976 | 1976 | 0 | 569.851582 | 569.851582 | 0.000000 | | 1978 | 1978 | 0 | 570.511303 | 570.511303 | 0.000000 | | min | max | avg | stddev | |-----+----------+------------+------------| | 0. | 1.004501 | 0.77996878 | 0.26165024 | #+tblfm: $1=vmin(remote(new-gc-default-rep,@<<$6..@>$6))::$2=vmax(remote(new-gc-default-rep,@<<$6..@>$6))::$3=vmean(remote(new-gc-default-rep,@<<$6..@>$6))::$4=vsdev(remote(new-gc-default-rep,@<<$6..@>$6)) ELP results: #+NAME: new-elp-otr-rep | Function Name | Call Count | Elapsed Time | Average Time | |-----------------------+------------+--------------+--------------| | org-table-recalculate | 3 | 3.602455605 | 1.200818535 | | org-table-recalculate | 3 | 4.601049409 | 1.5336831363 | | org-table-recalculate | 3 | 3.934937821 | 1.3116459403 | | org-table-recalculate | 3 | 4.594367169 | 1.5314557229 | | org-table-recalculate | 3 | 3.9486397760 | 1.3162132586 | | org-table-recalculate | 3 | 4.2893050450 | 1.4297683483 | | org-table-recalculate | 3 | 3.934609579 | 1.3115365263 | | org-table-recalculate | 3 | 3.611487882 | 1.203829294 | | org-table-recalculate | 3 | 4.611609242 | 1.5372030806 | | org-table-recalculate | 3 | 3.9416291149 | 1.3138763716 | | min | max | avg | stddev | |-----------+-----------+-----------+------------| | 1.2008185 | 1.5372031 | 1.3690030 | 0.13058859 | #+tblfm: $1=vmin(remote(new-elp-otr-rep,@<<$4..@>$4))::$2=vmax(remote(new-elp-otr-rep,@<<$4..@>$4))::$3=vmean(remote(new-elp-otr-rep,@<<$4..@>$4))::$4=vsdev(remote(new-elp-otr-rep,@<<$4..@>$4)) | min | max | avg | stddev | |-----------+-----------+-----------+------------| | 3.6024556 | 4.6116092 | 4.1070091 | 0.39176578 | #+tblfm: $1=vmin(remote(new-elp-otr-rep,@<<$3..@>$3))::$2=vmax(remote(new-elp-otr-rep,@<<$3..@>$3))::$3=vmean(remote(new-elp-otr-rep,@<<$3..@>$3))::$4=vsdev(remote(new-elp-otr-rep,@<<$3..@>$3)) #+NAME: new-elp-mrps-rep | Function Name | Call Count | Elapsed Time | Average Time | |-----------------------------+------------+--------------+--------------| | math-read-preprocess-string | 1062 | 0.3885816630 | 0.0003658961 | | math-read-preprocess-string | 1062 | 0.3892037710 | 0.0003664818 | | math-read-preprocess-string | 1062 | 0.7196623169 | 0.0006776481 | | math-read-preprocess-string | 1062 | 0.055396946 | 5.216e-05 | | math-read-preprocess-string | 1062 | 0.3883244280 | 0.0003656538 | | math-read-preprocess-string | 1062 | 0.3913531000 | 0.0003685057 | | math-read-preprocess-string | 1062 | 0.0541917650 | 5.102e-05 | | math-read-preprocess-string | 1062 | 0.0549385280 | 5.173e-05 | | math-read-preprocess-string | 1062 | 0.3868773030 | 0.0003642912 | | math-read-preprocess-string | 1062 | 0.3887666309 | 0.0003660702 | | min | max | avg | stddev | |----------+-------------+--------------+--------------| | 5.102e-5 | 6.776481e-4 | 3.0294569e-4 | 1.9828409e-4 | #+tblfm: $1=vmin(remote(new-elp-mrps-rep,@<<$4..@>$4))::$2=vmax(remote(new-elp-mrps-rep,@<<$4..@>$4))::$3=vmean(remote(new-elp-mrps-rep,@<<$4..@>$4))::$4=vsdev(remote(new-elp-mrps-rep,@<<$4..@>$4)) | min | max | avg | stddev | |-------------+------------+------------+------------| | 0.054191765 | 0.71966232 | 0.32172965 | 0.21057592 | #+tblfm: $1=vmin(remote(new-elp-mrps-rep,@<<$3..@>$3))::$2=vmax(remote(new-elp-mrps-rep,@<<$3..@>$3))::$3=vmean(remote(new-elp-mrps-rep,@<<$3..@>$3))::$4=vsdev(remote(new-elp-mrps-rep,@<<$3..@>$3)) ** GC prevented *** Table without replacements ELP results: #+NAME: new-elp-otr-gcp | Function Name | Call Count | Elapsed Time | Average Time | |-----------------------+------------+--------------+--------------| | org-table-recalculate | 3 | 2.493044023 | 0.8310146743 | | org-table-recalculate | 3 | 2.512677176 | 0.8375590586 | | org-table-recalculate | 3 | 2.538733559 | 0.8462445196 | | org-table-recalculate | 3 | 2.5243518540 | 0.8414506180 | | org-table-recalculate | 3 | 2.507517527 | 0.8358391756 | | org-table-recalculate | 3 | 2.569699372 | 0.8565664573 | | org-table-recalculate | 3 | 2.468403993 | 0.822801331 | | org-table-recalculate | 3 | 2.512327016 | 0.8374423386 | | org-table-recalculate | 3 | 2.478930529 | 0.8263101763 | | org-table-recalculate | 3 | 2.537201331 | 0.845733777 | | min | max | avg | stddev | |------------+------------+------------+-------------| | 0.82280133 | 0.85656646 | 0.83809621 | 0.010032900 | #+tblfm: $1=vmin(remote(new-elp-otr-gcp,@<<$4..@>$4))::$2=vmax(remote(new-elp-otr-gcp,@<<$4..@>$4))::$3=vmean(remote(new-elp-otr-gcp,@<<$4..@>$4))::$4=vsdev(remote(new-elp-otr-gcp,@<<$4..@>$4)) | min | max | avg | stddev | |-----------+-----------+-----------+-------------| | 2.4684040 | 2.5696994 | 2.5142886 | 0.030098701 | #+tblfm: $1=vmin(remote(new-elp-otr-gcp,@<<$3..@>$3))::$2=vmax(remote(new-elp-otr-gcp,@<<$3..@>$3))::$3=vmean(remote(new-elp-otr-gcp,@<<$3..@>$3))::$4=vsdev(remote(new-elp-otr-gcp,@<<$3..@>$3)) #+NAME: new-elp-mrps-gcp | Function Name | Call Count | Elapsed Time | Average Time | |-----------------------------+------------+--------------+--------------| | math-read-preprocess-string | 1071 | 0.0347882809 | 3.248e-05 | | math-read-preprocess-string | 1071 | 0.0353020950 | 3.296e-05 | | math-read-preprocess-string | 1071 | 0.0348920780 | 3.257e-05 | | math-read-preprocess-string | 1071 | 0.0345307570 | 3.224e-05 | | math-read-preprocess-string | 1071 | 0.0345681400 | 3.227e-05 | | math-read-preprocess-string | 1071 | 0.0347633370 | 3.245e-05 | | math-read-preprocess-string | 1071 | 0.0349174600 | 3.260e-05 | | math-read-preprocess-string | 1071 | 0.034960621 | 3.264e-05 | | math-read-preprocess-string | 1071 | 0.0350518849 | 3.272e-05 | | math-read-preprocess-string | 1071 | 0.0347729759 | 3.246e-05 | | min | max | avg | stddev | |----------+----------+-----------+--------------| | 3.224e-5 | 3.296e-5 | 3.2539e-5 | 2.1194601e-7 | #+tblfm: $1=vmin(remote(new-elp-mrps-gcp,@<<$4..@>$4))::$2=vmax(remote(new-elp-mrps-gcp,@<<$4..@>$4))::$3=vmean(remote(new-elp-mrps-gcp,@<<$4..@>$4))::$4=vsdev(remote(new-elp-mrps-gcp,@<<$4..@>$4)) | min | max | avg | stddev | |-------------+-------------+-------------+--------------| | 0.034530757 | 0.035302095 | 0.034854763 | 2.2659130e-4 | #+tblfm: $1=vmin(remote(new-elp-mrps-gcp,@<<$3..@>$3))::$2=vmax(remote(new-elp-mrps-gcp,@<<$3..@>$3))::$3=vmean(remote(new-elp-mrps-gcp,@<<$3..@>$3))::$4=vsdev(remote(new-elp-mrps-gcp,@<<$3..@>$3)) *** Table with replacements ELP results: #+NAME: new-elp-otr-gcp-rep | Function Name | Call Count | Elapsed Time | Average Time | |-----------------------+------------+--------------+--------------| | org-table-recalculate | 3 | 2.927262049 | 0.9757540163 | | org-table-recalculate | 3 | 2.97768807 | 0.9925626900 | | org-table-recalculate | 3 | 2.875336418 | 0.9584454726 | | org-table-recalculate | 3 | 2.9480709679 | 0.9826903226 | | org-table-recalculate | 3 | 2.95586239 | 0.9852874633 | | org-table-recalculate | 3 | 2.984782702 | 0.9949275673 | | org-table-recalculate | 3 | 2.9521534359 | 0.9840511453 | | org-table-recalculate | 3 | 2.962699571 | 0.9875665236 | | org-table-recalculate | 3 | 2.951152968 | 0.983717656 | | org-table-recalculate | 3 | 2.9822409910 | 0.9940803303 | | min | max | avg | stddev | |------------+------------+------------+-------------| | 0.95844547 | 0.99492757 | 0.98390832 | 0.010705480 | #+tblfm: $1=vmin(remote(new-elp-otr-gcp-rep,@<<$4..@>$4))::$2=vmax(remote(new-elp-otr-gcp-rep,@<<$4..@>$4))::$3=vmean(remote(new-elp-otr-gcp-rep,@<<$4..@>$4))::$4=vsdev(remote(new-elp-otr-gcp-rep,@<<$4..@>$4)) | min | max | avg | stddev | |-----------+-----------+-----------+-------------| | 2.8753364 | 2.9847827 | 2.9517250 | 0.032116440 | #+tblfm: $1=vmin(remote(new-elp-otr-gcp-rep,@<<$3..@>$3))::$2=vmax(remote(new-elp-otr-gcp-rep,@<<$3..@>$3))::$3=vmean(remote(new-elp-otr-gcp-rep,@<<$3..@>$3))::$4=vsdev(remote(new-elp-otr-gcp-rep,@<<$3..@>$3)) #+NAME: new-elp-mrps-gcp-rep | Function Name | Call Count | Elapsed Time | Average Time | |-----------------------------+------------+--------------+--------------| | math-read-preprocess-string | 1062 | 0.0522976359 | 4.924e-05 | | math-read-preprocess-string | 1062 | 0.0525888469 | 4.951e-05 | | math-read-preprocess-string | 1062 | 0.0525499260 | 4.948e-05 | | math-read-preprocess-string | 1062 | 0.0524278629 | 4.936e-05 | | math-read-preprocess-string | 1062 | 0.0523294250 | 4.927e-05 | | math-read-preprocess-string | 1062 | 0.0527783960 | 4.969e-05 | | math-read-preprocess-string | 1062 | 0.0524896099 | 4.942e-05 | | math-read-preprocess-string | 1062 | 0.052624055 | 4.955e-05 | | math-read-preprocess-string | 1062 | 0.0526563890 | 4.958e-05 | | math-read-preprocess-string | 1062 | 0.0524006549 | 4.934e-05 | | min | max | avg | stddev | |----------+----------+-----------+--------------| | 4.924e-5 | 4.969e-5 | 4.9444e-5 | 1.4385178e-7 | #+tblfm: $1=vmin(remote(new-elp-mrps-gcp-rep,@<<$4..@>$4))::$2=vmax(remote(new-elp-mrps-gcp-rep,@<<$4..@>$4))::$3=vmean(remote(new-elp-mrps-gcp-rep,@<<$4..@>$4))::$4=vsdev(remote(new-elp-mrps-gcp-rep,@<<$4..@>$4)) | min | max | avg | stddev | |-------------+-------------+-------------+--------------| | 0.052297636 | 0.052778396 | 0.052514280 | 1.5308925e-4 | #+tblfm: $1=vmin(remote(new-elp-mrps-gcp-rep,@<<$3..@>$3))::$2=vmax(remote(new-elp-mrps-gcp-rep,@<<$3..@>$3))::$3=vmean(remote(new-elp-mrps-gcp-rep,@<<$3..@>$3))::$4=vsdev(remote(new-elp-mrps-gcp-rep,@<<$3..@>$3)) --=-=-=-- From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 16 Dec 2023 09:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: mattias.engdegard@gmail.com, Raffael Stocker Cc: monnier@iro.umontreal.ca, 67536@debbugs.gnu.org Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.17027196795436 (code B ref 67536); Sat, 16 Dec 2023 09:42:02 +0000 Received: (at 67536) by debbugs.gnu.org; 16 Dec 2023 09:41:19 +0000 Received: from localhost ([127.0.0.1]:53981 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rERAc-0001Pc-Oe for submit@debbugs.gnu.org; Sat, 16 Dec 2023 04:41:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38126) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rERAa-0001PO-VQ for 67536@debbugs.gnu.org; Sat, 16 Dec 2023 04:41:17 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rERAT-0004Jm-Sl; Sat, 16 Dec 2023 04:41:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=ztm529BiqXmY2igzFndxo22uLHPC2kQQR+T7UWTrcA0=; b=T3gLMQZbCd3KsJLWsgjB qTA2XlSRMPnfcuJEv/rzn8Kf3XGnSG5Qt+r0uO9BxlSWd/4UfkfB87DDS2eH1KNJIhDAniQ16Ug85 bs3MAtMtkuFLXmohmvCGt1UKkOq3IRXKJCsBqJKqtfgq5fwaMdD/L/Fd4cR6BSPuLKeIVKfAmrvCT dLpUCrS9hddYiJ9aQZVPUClu/YCRLVotRy96dJmh0vao6SwkaADVO19LjcIAAbv70xTFd49QI9bK7 qtqzbC6CKllCqLy4+OQZUNcAqYsPkf7H8qN92bXeWh6TQEXyucvJvLU50DOtdpyIUt39CgEfREZqP YejoSqk6sHitnA==; Date: Sat, 16 Dec 2023 11:40:21 +0200 Message-Id: <83y1dumqnu.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Raffael Stocker on Tue, 05 Dec 2023 19:14:36 +0100) References: <83h6l367zx.fsf@gnu.org> <83jzpzaw9s.fsf@gnu.org> <834jh1aj1d.fsf@gnu.org> <83lead81zq.fsf@gnu.org> <1B1320A5-9FE9-4747-8A07-6F7FF71E8840@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Mattias, is this okay with you? Should I install these patches? > From: Raffael Stocker > Cc: Eli Zaretskii , Stefan Monnier , > 67536@debbugs.gnu.org > Date: Tue, 05 Dec 2023 19:14:36 +0100 > > Mattias Engdegård writes: > > > Here's a new patch. > > A lot less pretty this time. > > > > In any case, make sure to include unit tests in your final patch. > > Ok, here it comes. > > I have constructed two org tables for the test (see test-input.org) that > are reasonably long and contain a few not too unreasonable formulas. > The nature of the formulas is not too important for the tests, I just > took them from my original "offending" table. > > I also added unit tests for the function, as requested. > > One of the tables has no special characters, so > ‘math-read-preprocess-string’ just has to walk through without doing any > real work (arguably the most common case). The other table is full of > replaceable stuff. I used these two tables to compare the original with > the new version of ‘math-read-preprocess-string’. The results are in > test-results.org. > > As before, I compared ‘gcs-done’ and ‘gc-elapsed’ (with standard > settings for ‘gc-cons-threshold’ and ‘gc-cons-percentage’) with both > versions and tables. I also instrumented ‘org-table-recalculate’ and > ‘math-read-preprocess-string’ using elp. Then I set ‘gc-cons-threshold’ > to a large value and ran the same tests again. For the latter test, I > only report ‘elp-results’ (as no GC was triggered). > > I recalculated every table three times per reported elp result, as it > takes three evaluations for the calculation to converge. > > Some interesting results are: > > - time spent in GC reduces from 2.11 s to 0.78 s for the second table > (with replacements) > - elp report of average time decreases from 4.6316224e-3 s to > 3.0294569e-4 s for the second table > - with GC prevented, elp reports avg. time 3.4286452e-4 s vs. 4.9444e-5 s > - elp report of elapsed time for ‘org-table-recalculate’ for three evaluations > (what the user sees) decreases from 8.36 s to 4.11 s (with standard GC > settings again) > > This is a real win especially for large tables. Needless to say, I am > very excited about this optimization. > > (Just for completeness, I quickly compared my version to Mattias' > version, the latter is about a factor of two faster according to elp.) > > Regards, > Raffael From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Dec 2023 10:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 67536@debbugs.gnu.org, monnier@iro.umontreal.ca, Raffael Stocker Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.170289692230905 (code B ref 67536); Mon, 18 Dec 2023 10:56:02 +0000 Received: (at 67536) by debbugs.gnu.org; 18 Dec 2023 10:55:22 +0000 Received: from localhost ([127.0.0.1]:59510 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFBHN-00082P-OR for submit@debbugs.gnu.org; Mon, 18 Dec 2023 05:55:22 -0500 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]:47189) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFBHM-000824-5F for 67536@debbugs.gnu.org; Mon, 18 Dec 2023 05:55:20 -0500 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-50e3cdcf010so399066e87.2 for <67536@debbugs.gnu.org>; Mon, 18 Dec 2023 02:55:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702896912; x=1703501712; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:from:to:cc:subject:date:message-id:reply-to; bh=pGoVbUNxL7Rb4iEYJIcSA1RvHsot7EDQnoFksq9pv5U=; b=llUWJrxemsSBVuYcpK6MDpTBUg6he9yMRwg7ygYlwtXx2Ru9PjMzCKhEi6RiJWLy1V FoHvUNkgnszhkEC+Q+eZwJzT4teHARAM6Z0hvW4HeksRzIV9AGoVbAlfWMYQL0UgFGaG rfjrOB4Eftfu8l1Xzj/TKVSYcv7U32X0eL/eUSwCxtGAsNqlVjDwZB6Ou9w0eD++WOyW hY5STEnGmhjifMGu6NeEOJU0H00OJEI4NpOW91yoXHDSKCoEmliTverTb1hJ51f6OAJh l0qL7V4bjkZoreeQWQAFVbb/V4LbjywDd3RsHDf/TlXVt1UjaZ7rrNIyhOWw1+2mOA+E r/RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702896912; x=1703501712; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pGoVbUNxL7Rb4iEYJIcSA1RvHsot7EDQnoFksq9pv5U=; b=CgAfBNKQa6zxwUmXvsC1wwwwEeozKUmZLJCNRfBmuLG8KBACZa2OvINCWKmopRxMmE Oo/lWMRkBBcJ9KVyp16xzSFCZmfWXNaRlG88k2xUw5vjHpI2i5g5IwIAr8KuIkYmZd/a PUkTvoZzjnc3hetUGIGIIkdyqWRduQx0lU1EEHA5wWL+nmobjYrn2otz9vdbLqCcx4dM fVuyrWv5mJcBLqTGntduTuJU4oqWy+Ak9PgK3X7GBA6WJEq1b9BJw3HzDCdESHIuabCM MU1w0QTegOXOlI3fbV7022MBHIN2B0NEeF4lTp1WVig1WIfIfgiJTQVn/NiP623V9v7y znyg== X-Gm-Message-State: AOJu0YwONx0s4YnZzNtr4mPMk1/MwuxX6mHdjdndV7qQlm8xV34C1Wqu NTAS8Nb99lraf0ayEDRm/Ww= X-Google-Smtp-Source: AGHT+IE4X0z5q4/9xhiyu2QvjcM/lsPs+IAT8HHMe1H59g7m6ROXksPO4KHB/13Nwp+hF9xXp82ZQA== X-Received: by 2002:a05:6512:ad5:b0:50d:1e4e:fcb4 with SMTP id n21-20020a0565120ad500b0050d1e4efcb4mr5282533lfu.2.1702896911612; Mon, 18 Dec 2023 02:55:11 -0800 (PST) Received: from smtpclient.apple (c80-217-1-132.bredband.tele2.se. [80.217.1.132]) by smtp.gmail.com with ESMTPSA id h20-20020a2e9ed4000000b002cc79630cdbsm15795ljk.2.2023.12.18.02.55.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2023 02:55:11 -0800 (PST) From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Message-Id: <11C36862-05F6-47B2-AFEB-D51B969EAAA5@gmail.com> Content-Type: multipart/mixed; boundary="Apple-Mail=_778A1229-A9BD-4A6D-9060-59B19624DCBA" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Date: Mon, 18 Dec 2023 11:55:10 +0100 In-Reply-To: <83y1dumqnu.fsf@gnu.org> References: <83h6l367zx.fsf@gnu.org> <83jzpzaw9s.fsf@gnu.org> <834jh1aj1d.fsf@gnu.org> <83lead81zq.fsf@gnu.org> <1B1320A5-9FE9-4747-8A07-6F7FF71E8840@gmail.com> <83y1dumqnu.fsf@gnu.org> X-Mailer: Apple Mail (2.3654.120.0.1.15) X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_778A1229-A9BD-4A6D-9060-59B19624DCBA Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 16 dec. 2023 kl. 10.40 skrev Eli Zaretskii : > Mattias, is this okay with you? Should I install these patches? So very sorry for the hiatus. I've been a bit poorly and getting back = will take some time. Raffael, thank you for your dogged measurements. Of course my clumsy = code didn't preserve the possibility for `math-read-replacement-list` to = translate strings longer than a single character but that's what I get = for sending off-cuff patches that way. Here's another off-cuff patch that might work better (demonstrating that = I've learned nothing). Again it's most likely that no user ever changes = `math-read-replacement-list=1E` and the code could be simplified a lot. --Apple-Mail=_778A1229-A9BD-4A6D-9060-59B19624DCBA Content-Disposition: attachment; filename=calc-aent.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="calc-aent.diff" Content-Transfer-Encoding: 7bit diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el index 131f31afff7..ae04a850f5d 100644 --- a/lisp/calc/calc-aent.el +++ b/lisp/calc/calc-aent.el @@ -562,8 +562,8 @@ math-read-preprocess-string ;; Cache invalid, recompute. (setq math--read-preprocess-re-cache (list (rx-to-string - `(or (group (+ (in ,math-read-superscripts))) - (group (+ (in ,math-read-subscripts))) + `(or (or (+ (in ,math-read-superscripts)) + (group (+ (in ,math-read-subscripts)))) (group (or ,@(mapcar #'car math-read-replacement-list)))) t) math-read-replacement-list @@ -572,13 +572,15 @@ math-read-preprocess-string (replace-regexp-in-string (nth 0 math--read-preprocess-re-cache) (lambda (s) - (let ((r (mapconcat (lambda (c) - (cadr (assoc (char-to-string c) - math-read-replacement-list))) - s))) - (cond ((match-beginning 1) (concat "^(" r ")")) - ((match-beginning 2) (concat "_(" r ")")) - (t r)))) + (if (match-beginning 2) + (cadr (assoc s math-read-replacement-list)) + (concat (if (match-beginning 1) "_" "^") + "(" + (mapconcat (lambda (c) + (cadr (assoc (char-to-string c) + math-read-replacement-list))) + s) + ")"))) str t)) ;; The next few variables are local to math-read-exprs (and math-read-expr --Apple-Mail=_778A1229-A9BD-4A6D-9060-59B19624DCBA-- From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Raffael Stocker Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Dec 2023 11:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: Eli Zaretskii , monnier@iro.umontreal.ca, 67536@debbugs.gnu.org Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.17028999228573 (code B ref 67536); Mon, 18 Dec 2023 11:46:01 +0000 Received: (at 67536) by debbugs.gnu.org; 18 Dec 2023 11:45:22 +0000 Received: from localhost ([127.0.0.1]:59539 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFC3l-0002Ck-Bo for submit@debbugs.gnu.org; Mon, 18 Dec 2023 06:45:22 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:33241) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFC3j-00024E-0W for 67536@debbugs.gnu.org; Mon, 18 Dec 2023 06:45:20 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4StygH0YmJz1qsP8; Mon, 18 Dec 2023 12:45:14 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 4StygG5gd0z1qqlW; Mon, 18 Dec 2023 12:45:14 +0100 (CET) X-Virus-Scanned: amavis at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavis, port 10024) with ESMTP id KHWmxU53ck8V; Mon, 18 Dec 2023 12:45:13 +0100 (CET) X-Auth-Info: P682YascQw/Er2gprlxQ0OS/tvg4K+BJt727CVjZowaO/pp5+URrVR1dw0b8h/FS Received: from Whiteflame (ppp-212-114-182-217.dynamic.mnet-online.de [212.114.182.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Mon, 18 Dec 2023 12:45:13 +0100 (CET) References: <83h6l367zx.fsf@gnu.org> <83jzpzaw9s.fsf@gnu.org> <834jh1aj1d.fsf@gnu.org> <83lead81zq.fsf@gnu.org> <1B1320A5-9FE9-4747-8A07-6F7FF71E8840@gmail.com> <83y1dumqnu.fsf@gnu.org> <11C36862-05F6-47B2-AFEB-D51B969EAAA5@gmail.com> User-agent: mu4e 1.10.8; emacs 29.1 From: Raffael Stocker Date: Mon, 18 Dec 2023 12:39:01 +0100 In-reply-to: <11C36862-05F6-47B2-AFEB-D51B969EAAA5@gmail.com> Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mattias Engdeg=C3=A5rd writes: > Of course my clumsy code didn't preserve the possibility for > `math-read-replacement-list` to translate strings longer than a single > character but that's what I get for sending off-cuff patches that way. ...and my test did not catch that edge case. I extended the test with this and an empty =E2=80=98math-read-replacement-list=E2=80=99 for good mea= sure (although I don't quite know which use case that might be). The test fails for the previous version and succeeds for the original and this new one. Have I missed any other edge cases in the test? I appended the updated patch. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-lisp-calc-calc-aent.el-math-read-preprocess-string-o.patch Content-Transfer-Encoding: quoted-printable Content-Description: 0001-lisp-calc-calc-aent.el-math-read-preprocess-string-o.patch >From 66f63f993d87161cfeaf07366eb9dc68738b5891 Mon Sep 17 00:00:00 2001 From: Raffael Stocker Date: Mon, 18 Dec 2023 12:35:33 +0100 Subject: [PATCH] * lisp/calc/calc-aent.el (math-read-preprocess-string): optimize (bug#67536) MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit This is an optimized version of =E2=80=98math-read-preprocess-string=E2=80= =99 by Mattias Engdeg=C3=A5rd , with unit tests. This function is called by calc-eval, which in turn is called repeatedly when re-calculating org-mode tables. It was one of the main bottlenecks there and this optimization addresses this by not repeatedly allocating new strings while iterating through the replacement list, but instead working through the argument string only once, using a "flattened" and cached regexp and only one call to =E2=80=98replace-regexp-in-string=E2=80=99. --- lisp/calc/calc-aent.el | 45 +++++++++++++++++++++++++----------- test/lisp/calc/calc-tests.el | 37 +++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 13 deletions(-) diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el index 66ede3295ae..ae04a850f5d 100644 --- a/lisp/calc/calc-aent.el +++ b/lisp/calc/calc-aent.el @@ -547,22 +547,41 @@ math-read-subscripts "=E2=82=80=E2=82=81=E2=82=82=E2=82=83=E2=82=84=E2=82=85=E2=82=86=E2=82= =87=E2=82=88=E2=82=89=E2=82=8A=E2=82=8B=E2=82=8D=E2=82=8E" ; 0123456789+-() "A string consisting of the subscripts allowed by Calc.") =20 +(defvar math--read-preprocess-re-cache nil + "Cached regexp and tag: (REGEXP REPLACEMENTS SUPERSCRIPTS SUBSCRIPTS)") + ;;;###autoload (defun math-read-preprocess-string (str) "Replace some substrings of STR by Calc equivalents." - (setq str - (replace-regexp-in-string (concat "[" math-read-superscripts "]+") - "^(\\&)" str)) - (setq str - (replace-regexp-in-string (concat "[" math-read-subscripts "]+") - "_(\\&)" str)) - (let ((rep-list math-read-replacement-list)) - (while rep-list - (setq str - (replace-regexp-in-string (nth 0 (car rep-list)) - (nth 1 (car rep-list)) str)) - (setq rep-list (cdr rep-list)))) - str) + (unless (and (eq (nth 1 math--read-preprocess-re-cache) + math-read-replacement-list) + (eq (nth 2 math--read-preprocess-re-cache) + math-read-superscripts) + (eq (nth 3 math--read-preprocess-re-cache) + math-read-subscripts)) + ;; Cache invalid, recompute. + (setq math--read-preprocess-re-cache + (list (rx-to-string + `(or (or (+ (in ,math-read-superscripts)) + (group (+ (in ,math-read-subscripts)))) + (group (or ,@(mapcar #'car math-read-replacement-lis= t)))) + t) + math-read-replacement-list + math-read-superscripts + math-read-subscripts))) + (replace-regexp-in-string + (nth 0 math--read-preprocess-re-cache) + (lambda (s) + (if (match-beginning 2) + (cadr (assoc s math-read-replacement-list)) + (concat (if (match-beginning 1) "_" "^") + "(" + (mapconcat (lambda (c) + (cadr (assoc (char-to-string c) + math-read-replacement-list))) + s) + ")"))) + str t)) =20 ;; The next few variables are local to math-read-exprs (and math-read-expr ;; in calc-ext.el), but are set in functions they call. diff --git a/test/lisp/calc/calc-tests.el b/test/lisp/calc/calc-tests.el index 5b11dd950ba..e49df216019 100644 --- a/test/lisp/calc/calc-tests.el +++ b/test/lisp/calc/calc-tests.el @@ -816,5 +816,42 @@ calc-nth-root (x (calc-tests--calc-to-number (math-pow 8 '(frac 1 6))))) (should (< (abs (- x (sqrt 2.0))) 1.0e-10)))) =20 +(ert-deftest calc-math-read-preprocess-string () + "Test replacement of allowed special Unicode symbols." + ;; ... doesn't change an empty string + (should (string=3D "" (math-read-preprocess-string ""))) + ;; ... doesn't change a string without characters from + ;; =E2=80=98math-read-replacement-list=E2=80=99 + (let ((str "don't replace here")) + (should (string=3D str (math-read-preprocess-string str)))) + ;; ... replaces irrespective of position in input string + (should (string=3D "^(1)" (math-read-preprocess-string "=C2=B9"))) + (should (string=3D "some^(1)" (math-read-preprocess-string "some=C2=B9")= )) + (should (string=3D "^(1)time" (math-read-preprocess-string "=C2=B9time")= )) + (should (string=3D "some^(1)else" (math-read-preprocess-string "some=C2= =B9else"))) + ;; ... replaces every element of =E2=80=98math-read-replacement-list=E2= =80=99 correctly, + ;; in particular combining consecutive super-/subscripts into one + ;; exponent/subscript + (should (string=3D (concat "+/-*:-/*inf<=3D>=3D<=3D>=3D=CE=BC(1:4)(1:2)(= 3:4)(1:3)(2:3)" + "(1:5)(2:5)(3:5)(4:5)(1:6)(5:6)" + "(1:8)(3:8)(5:8)(7:8)1:^(0123456789+-()ni)" + "_(0123456789+-())") + (math-read-preprocess-string (mapconcat #'car + math-read-repla= cement-list + "")))) + ;; ... replaces strings of more than a single character correctly + (let ((math-read-replacement-list (append + math-read-replacement-list + '(("=F0=9D=9A=A4=F0=9D=9A=A5" "ij")) + '(("=C2=BC=C2=BD" "(1:4)(1:2)"))))) + (should (string=3D "(1:4)(1:2)ij" + (math-read-preprocess-string "=C2=BC=C2=BD=F0=9D=9A= =A4=F0=9D=9A=A5")))) + ;; ... handles an empty replacement list gracefully + (let ((math-read-replacement-list '())) + (should (string=3D "=C2=BC" (math-read-preprocess-string "=C2=BC")))) + ;; ... signals an error if the argument is not a string + (should-error (math-read-preprocess-string nil)) + (should-error (math-read-preprocess-string 42))) + (provide 'calc-tests) ;;; calc-tests.el ends here --=20 2.43.0 --=-=-=-- From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 19 Dec 2023 16:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Raffael Stocker Cc: Eli Zaretskii , monnier@iro.umontreal.ca, 67536@debbugs.gnu.org Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.170300258425084 (code B ref 67536); Tue, 19 Dec 2023 16:17:02 +0000 Received: (at 67536) by debbugs.gnu.org; 19 Dec 2023 16:16:24 +0000 Received: from localhost ([127.0.0.1]:37131 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFclc-0006WW-1f for submit@debbugs.gnu.org; Tue, 19 Dec 2023 11:16:24 -0500 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]:61530) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFclZ-0006WG-8R for 67536@debbugs.gnu.org; Tue, 19 Dec 2023 11:16:22 -0500 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2ca0f21e48cso58628081fa.2 for <67536@debbugs.gnu.org>; Tue, 19 Dec 2023 08:16:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703002572; x=1703607372; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:from:to:cc:subject :date:message-id:reply-to; bh=SDg2lhu8DiLJyxR9SsXutEKpxPt9SzOhe02t80k9Keg=; b=WMv2KQPx+dVjAp2xSA0M3ADOE3HWHbzdRavK2ovgQ/evYqhBNzlpPn1Zq7sBO4l+S3 oj9ARh/75U3q+AoFVONuuwWOHewjzyOLKg9dIiNvDLPBeSoQFClAP6+rd8LnYRNRSTQS 3Y7HWMdZlDLjBR4371Mkq/hPVuyjHuFjuhXkbIhzi95UJNvXq2T8w3GX+XarX3OYYaip 6Lo/uL7jqJdOZ2siXnVaXL3dzYO6av1IReN0sQ2M2qZ08cL34ocsjM5CG6cM6L8dyEXQ MLhQ/eTZU0efhg1ibdBMfYiOq1T/V+QPRuAaEayGqU+VH/6C5v30ViQExgewTJEudp2G 3Ciw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703002572; x=1703607372; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=SDg2lhu8DiLJyxR9SsXutEKpxPt9SzOhe02t80k9Keg=; b=lHne7Bbyh/hVPu4UM9XTpH7ZXmrshS0i6kcXQ1K19Ap2sFBihHYZVOtrt6zZfPVdrC yE9W8iX6f5ZyJMmeSwMBspciS7UtuHYOvqrKB73c1JLgzRAc7o3DbZkIkW8J/Vt+PjsF JruSB9kKNOx6LQ6Ic6vF2Fzl98a58/cvo+x6BeJfN8mD1IL5uv6brZVMrdUVlIXZ7Llc tkvJbQR1OW8oP5Oht0Orsv+rBKJUBlZ5MIR42tvkfHwdSS1h08y9IUAKh/eO2TaslWeX mgAA2gt8aDBSxHjzTgCSQNc5Dlp8Vyn9Boaxms+/9a+kB+lFspqu3wDyFXp7A0RiCF0F b/mQ== X-Gm-Message-State: AOJu0YwkNYCbU960r/aLC/xwwGmVUNi2s2SkJoEHQ5rWS0UHO5aVAjUH BYHo+a2pD+3oErYWEJrPOQc= X-Google-Smtp-Source: AGHT+IGeZn5ci+xv4TA3SahEb+Ewiwx5vEYegYDvGoCguijSbK4wbbhpWvbXG78cOYXEfBgZ2al3jQ== X-Received: by 2002:a2e:9852:0:b0:2cc:7fb9:430a with SMTP id e18-20020a2e9852000000b002cc7fb9430amr741739ljj.58.1703002572354; Tue, 19 Dec 2023 08:16:12 -0800 (PST) Received: from smtpclient.apple (c80-217-1-132.bredband.tele2.se. [80.217.1.132]) by smtp.gmail.com with ESMTPSA id h1-20020a05651c158100b002cc6843108bsm1152069ljq.41.2023.12.19.08.16.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Dec 2023 08:16:12 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= In-Reply-To: Date: Tue, 19 Dec 2023 17:16:10 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <83h6l367zx.fsf@gnu.org> <83jzpzaw9s.fsf@gnu.org> <834jh1aj1d.fsf@gnu.org> <83lead81zq.fsf@gnu.org> <1B1320A5-9FE9-4747-8A07-6F7FF71E8840@gmail.com> <83y1dumqnu.fsf@gnu.org> <11C36862-05F6-47B2-AFEB-D51B969EAAA5@gmail.com> X-Mailer: Apple Mail (2.3654.120.0.1.15) X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 18 dec. 2023 kl. 12.39 skrev Raffael Stocker : > ...and my test did not catch that edge case. I extended the test with > this and an empty =E2=80=98math-read-replacement-list=E2=80=99 for = good measure > (although I don't quite know which use case that might be). The test > fails for the previous version and succeeds for the original and this > new one. Thanks, now pushed to master. The code could be sped up further if necessary but I suppose this will = do for now. Otherwise, let us know. From unknown Sun Jun 22 04:33:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Resent-From: Raffael Stocker Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 19 Dec 2023 17:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: Eli Zaretskii , monnier@iro.umontreal.ca, 67536@debbugs.gnu.org Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.170300584228056 (code B ref 67536); Tue, 19 Dec 2023 17:11:01 +0000 Received: (at 67536) by debbugs.gnu.org; 19 Dec 2023 17:10:42 +0000 Received: from localhost ([127.0.0.1]:37252 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFdc9-0007IS-Tg for submit@debbugs.gnu.org; Tue, 19 Dec 2023 12:10:42 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:57597) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFdc7-0007IG-7s for 67536@debbugs.gnu.org; Tue, 19 Dec 2023 12:10:41 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Svjr95KThz1syCS; Tue, 19 Dec 2023 18:10:33 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 4Svjr924Dgz1qqlW; Tue, 19 Dec 2023 18:10:33 +0100 (CET) X-Virus-Scanned: amavis at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavis, port 10024) with ESMTP id duGJsc7ifwmL; Tue, 19 Dec 2023 18:10:32 +0100 (CET) X-Auth-Info: B8vS+BPfS6bjsgKsoBA73pA1OsRctp43N1cQ9+dEuMDBISUpHWhfGvZcWBNpxgp8 Received: from Whiteflame (ppp-212-114-182-217.dynamic.mnet-online.de [212.114.182.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 19 Dec 2023 18:10:32 +0100 (CET) References: <83h6l367zx.fsf@gnu.org> <83jzpzaw9s.fsf@gnu.org> <834jh1aj1d.fsf@gnu.org> <83lead81zq.fsf@gnu.org> <1B1320A5-9FE9-4747-8A07-6F7FF71E8840@gmail.com> <83y1dumqnu.fsf@gnu.org> <11C36862-05F6-47B2-AFEB-D51B969EAAA5@gmail.com> User-agent: mu4e 1.10.8; emacs 29.1 From: Raffael Stocker Date: Tue, 19 Dec 2023 18:09:58 +0100 In-reply-to: Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Mattias Engdeg=C3=A5rd writes: > 18 dec. 2023 kl. 12.39 skrev Raffael Stocker : > >> ...and my test did not catch that edge case. I extended the test with >> this and an empty =E2=80=98math-read-replacement-list=E2=80=99 for good = measure >> (although I don't quite know which use case that might be). The test >> fails for the previous version and succeeds for the original and this >> new one. > > Thanks, now pushed to master. > The code could be sped up further if necessary but I suppose this will do= for now. Otherwise, let us know. Yes, I think this will be fine. Thanks! From unknown Sun Jun 22 04:33:30 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Raffael Stocker Subject: bug#67536: closed (Re: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily) Message-ID: References: <1AE03DA1-3CE0-4897-A45D-59C5C5151A25@gmail.com> X-Gnu-PR-Message: they-closed 67536 X-Gnu-PR-Package: emacs Reply-To: 67536@debbugs.gnu.org Date: Tue, 19 Dec 2023 18:16:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1703009762-18427-1" This is a multi-part message in MIME format... ------------=_1703009762-18427-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 67536@debbugs.gnu.org. --=20 67536: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D67536 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1703009762-18427-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 67536-done) by debbugs.gnu.org; 19 Dec 2023 18:15:51 +0000 Received: from localhost ([127.0.0.1]:37290 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFedD-0004S4-DT for submit@debbugs.gnu.org; Tue, 19 Dec 2023 13:15:51 -0500 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]:47604) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFedB-0004DW-7C for 67536-done@debbugs.gnu.org; Tue, 19 Dec 2023 13:15:50 -0500 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2cc7ba7d12eso16520111fa.3 for <67536-done@debbugs.gnu.org>; Tue, 19 Dec 2023 10:15:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703009740; x=1703614540; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:from:to:cc:subject :date:message-id:reply-to; bh=yMQ+LIpnuiEDlQEsXu3Xb8ar836LdaPE+uw18ZqXu1Y=; b=h903hpbQBXxAx2jpoEi2qSE+PIc6dGlh4wo1Y/OFE/TOxLn9xs9Okzt/f452kJijo3 9CBqLd/DDQIKOrWQpXWF07uieYs1gdrGPFNurFHDF0s3U4fEF6wwNbclGwSy253socUa sxmHLCeilCpITlmlbq7bbI6IWKJIwvaTWARgBAPD1io3nxAkmXG5y21I/FojYu26mbrE imCJc4rOZAXvlxG+NE53yiSlCSqc/Q0yePFnJVePpNxE8EreFE8ciiiX7tcBWuvGh4Y5 8XQwD9SK2BeBOtRtAwmH3IOr5uAfna3NQpr1Cpw+s+3fqURM6RwGoj298ke9W+5Hcxfe SY/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703009740; x=1703614540; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=yMQ+LIpnuiEDlQEsXu3Xb8ar836LdaPE+uw18ZqXu1Y=; b=b38EXK21++1QS6jlq7uR3nbHXV0sh9k+8yK34QEDsUSuXPRdudM4BzVAcNULo+98CB rFalxky3uxzHa7RyBY8NZvolyd8nK3cZdJWe7rJZdU46QpfnfkEgL7bEBXO35tHj/c6w Mk7bBDABoXhJI1F2YqdGV9bnLVLBLezPdGZkk8ROdHXtRxPzi2kGX542UL2qlzWmOUlz BqILCfNFlcoHYQRkeQ7kyGOcwgLh8xPR35Rm3jfY1QZqo+9pB2MOSmOfEJBRR59E+mG/ rpLfS5fgE9mpd5Tl411bzcO+kMq3cmorzu5Y8OzBBwXfU57VSolqkTfzMc2UXDIQCBJ8 we0Q== X-Gm-Message-State: AOJu0YwadUAAp2/eX1zkrfCZe/+EE18/4ImyA9ueONesArIFq2YoS7rr pHzmB3bH9GqOCcu94CMWe70= X-Google-Smtp-Source: AGHT+IFb1uREVF3E6H3mhzAo+LvdsRf9bg778TmGL88Etv1FKpmFhday7b8zsD9kbfutQI5+J/o2bA== X-Received: by 2002:a2e:95d4:0:b0:2cc:5a8b:1f18 with SMTP id y20-20020a2e95d4000000b002cc5a8b1f18mr2134050ljh.89.1703009740188; Tue, 19 Dec 2023 10:15:40 -0800 (PST) Received: from smtpclient.apple (c80-217-1-132.bredband.tele2.se. [80.217.1.132]) by smtp.gmail.com with ESMTPSA id f18-20020a05651c161200b002cc7804390csm623365ljq.48.2023.12.19.10.15.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Dec 2023 10:15:39 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Subject: Re: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: Date: Tue, 19 Dec 2023 19:15:38 +0100 Content-Transfer-Encoding: 7bit Message-Id: <1AE03DA1-3CE0-4897-A45D-59C5C5151A25@gmail.com> References: <83h6l367zx.fsf@gnu.org> <83jzpzaw9s.fsf@gnu.org> <834jh1aj1d.fsf@gnu.org> <83lead81zq.fsf@gnu.org> <1B1320A5-9FE9-4747-8A07-6F7FF71E8840@gmail.com> <83y1dumqnu.fsf@gnu.org> <11C36862-05F6-47B2-AFEB-D51B969EAAA5@gmail.com> To: Raffael Stocker X-Mailer: Apple Mail (2.3654.120.0.1.15) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67536-done Cc: Eli Zaretskii , 67536-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 19 dec. 2023 kl. 18.09 skrev Raffael Stocker : > Yes, I think this will be fine. Thanks! Closing. ------------=_1703009762-18427-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 29 Nov 2023 21:31:13 +0000 Received: from localhost ([127.0.0.1]:51624 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8S9J-0003Pt-Co for submit@debbugs.gnu.org; Wed, 29 Nov 2023 16:31:13 -0500 Received: from lists.gnu.org ([2001:470:142::17]:44922) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8S9G-0003KJ-Uu for submit@debbugs.gnu.org; Wed, 29 Nov 2023 16:31:11 -0500 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 1r8S90-0001Af-UO for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 16:30:56 -0500 Received: from mail-out.m-online.net ([212.18.0.9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r8S8y-0005wG-Nq for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 16:30:54 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4SgXY75BPbz1qsP0 for ; Wed, 29 Nov 2023 22:30:19 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 4SgXY74DmBz1qqlS for ; Wed, 29 Nov 2023 22:30:19 +0100 (CET) X-Virus-Scanned: amavis at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavis, port 10024) with ESMTP id PW3vS2HFt88T for ; Wed, 29 Nov 2023 22:30:18 +0100 (CET) X-Auth-Info: 8TwOdn/C5t4VAAYPUyY3SkDRDhI0qO1AfYuFiJpGgGyjfCoAIfhAAcD8PNQt4Ssm Received: from Whiteflame (ppp-212-114-182-133.dynamic.mnet-online.de [212.114.182.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA for ; Wed, 29 Nov 2023 22:30:18 +0100 (CET) User-agent: mu4e 1.10.8; emacs 29.1 From: Raffael Stocker To: bug-gnu-emacs@gnu.org Subject: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Date: Wed, 29 Nov 2023 22:29:38 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=212.18.0.9; envelope-from=r.stocker@mnet-mail.de; helo=mail-out.m-online.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Org table re-calculation is very slow, partly due to math-read-preprocess-string of calc mode consing unnecessarily. For example, in one (large) table, I get the following memory usage from the profiler: ... 60,252,646 96% - org-ctrl-c-ctrl-c 60,248,166 96% - org-table-calc-current-TBLFM 60,216,431 96% - funcall-interactively 60,205,119 96% - org-table-recalculate 49,094,651 78% - org-table-eval-formula 32,624,631 52% - calc-eval 32,624,631 52% - calc-do-calc-eval 32,620,487 52% - calc-do-calc-eval 32,611,151 52% - math-read-exprs 29,388,838 47% + math-read-preprocess-string 2,343,257 3% + math-read-expr-list ... The reason for the slow-down seems to be that math-read-preprocess-string conses a lot, keeping the GC busy. This is due to heavy use of replace-regexp-in-string in this function: (defun math-read-preprocess-string (str) "Replace some substrings of STR by Calc equivalents." (setq str (replace-regexp-in-string (concat "[" math-read-superscripts "]+") "^(\\&)" str)) (setq str (replace-regexp-in-string (concat "[" math-read-subscripts "]+") "_(\\&)" str)) (let ((rep-list math-read-replacement-list)) (while rep-list ;; consing like a mad-man here: (setq str (replace-regexp-in-string (nth 0 (car rep-list)) (nth 1 (car rep-list)) str)) (setq rep-list (cdr rep-list)))) str) I would like to propose using a temp buffer instead of kneading the string into submission: (defun math-read-preprocess-string (str) "Replace some substrings of STR by Calc equivalents." (with-temp-buffer (insert str) (goto-char 0) (while (re-search-forward (concat "[" math-read-superscripts "]+") nil t) (replace-match "^(\\&)")) (goto-char 0) (while (re-search-forward (concat "[" math-read-subscripts "]+") nil t) (replace-match "_(\\&)")) (goto-char 0) (let ((rep-list math-read-replacement-list)) (while rep-list (while (re-search-forward (nth 0 (car rep-list)) nil t) (replace-match (nth 1 (car rep-list)))) (goto-char 0) (setq rep-list (cdr rep-list)))) (buffer-string))) With this replacement, the profiler shows much less memory usage on the same org table: ... 30,411,804 91% - org-ctrl-c-ctrl-c 30,407,324 91% - org-table-calc-current-TBLFM 30,363,932 91% - funcall-interactively 30,331,900 91% - org-table-recalculate 20,430,223 61% - org-table-eval-formula 6,751,852 20% + org-table-justify-field-maybe 4,598,523 13% - calc-eval 4,586,091 13% - calc-do-calc-eval 4,569,619 13% - calc-do-calc-eval 4,547,971 13% - math-read-exprs 2,297,453 6% + math-read-expr-list 1,347,377 4% + math-read-preprocess-string 7,296 0% math-read-token ... Only I am not sure the replacement is correct in all possible edge cases (or whether it uses so much less memory because I have overlooked something). What do you think? Can a calc-mode expert weigh in here? Regards, Raffael ------------=_1703009762-18427-1--