From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Date: Sat, 16 Dec 2023 11:40:21 +0200 Message-ID: <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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20133"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, 67536@debbugs.gnu.org To: mattias.engdegard@gmail.com, Raffael Stocker Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 16 10:42:21 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rERBc-00051u-J3 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 16 Dec 2023 10:42:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rERBK-0006r7-Nx; Sat, 16 Dec 2023 04:42:02 -0500 Original-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 1rERBJ-0006qy-VM for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2023 04:42:01 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rERBJ-0004NS-NS for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2023 04:42:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rERBK-0001Qc-5i for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2023 04:42:02 -0500 X-Loop: help-debbugs@gnu.org 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 Original-Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.17027196795436 (code B ref 67536); Sat, 16 Dec 2023 09:42:02 +0000 Original-Received: (at 67536) by debbugs.gnu.org; 16 Dec 2023 09:41:19 +0000 Original-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 Original-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 Original-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==; In-Reply-To: (message from Raffael Stocker on Tue, 05 Dec 2023 19:14:36 +0100) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:276307 Archived-At: 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