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: Thu, 30 Nov 2023 21:14:39 +0200 Message-ID: <83jzpzaw9s.fsf@gnu.org> References: <83h6l367zx.fsf@gnu.org> 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="12297"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67536@debbugs.gnu.org To: Raffael Stocker Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 30 20:16:11 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 1r8mWB-0002xs-Dw for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 30 Nov 2023 20:16:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r8mVz-0003Es-E3; Thu, 30 Nov 2023 14:15:59 -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 1r8mVu-0003DH-OZ for bug-gnu-emacs@gnu.org; Thu, 30 Nov 2023 14:15:54 -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 1r8mVu-0001xN-FV for bug-gnu-emacs@gnu.org; Thu, 30 Nov 2023 14:15:54 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r8mW1-0007y4-MM for bug-gnu-emacs@gnu.org; Thu, 30 Nov 2023 14:16:01 -0500 X-Loop: help-debbugs@gnu.org 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 Original-Received: via spool by 67536-submit@debbugs.gnu.org id=B67536.170137170330534 (code B ref 67536); Thu, 30 Nov 2023 19:16:01 +0000 Original-Received: (at 67536) by debbugs.gnu.org; 30 Nov 2023 19:15:03 +0000 Original-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 Original-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 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 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==; In-Reply-To: (message from Raffael Stocker on Thu, 30 Nov 2023 19:28:27 +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:275293 Archived-At: > 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.