GNU bug report logs - #67536
29.1; Calc mode's math-read-preprocess-string conses unnecessarily

Previous Next

Package: emacs;

Reported by: Raffael Stocker <r.stocker <at> mnet-mail.de>

Date: Wed, 29 Nov 2023 21:32:02 UTC

Severity: normal

Found in version 29.1

Done: Mattias Engdegård <mattias.engdegard <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 67536 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Raffael Stocker <r.stocker <at> mnet-mail.de>
Cc: 67536 <at> debbugs.gnu.org
Subject: Re: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses
 unnecessarily
Date: Thu, 30 Nov 2023 21:14:39 +0200
> From: Raffael Stocker <r.stocker <at> mnet-mail.de>
> Cc: 67536 <at> 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.




This bug report was last modified 1 year and 155 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.