From: Eli Zaretskii <eliz@gnu.org>
To: Raffael Stocker <r.stocker@mnet-mail.de>
Cc: 67536@debbugs.gnu.org
Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily
Date: Thu, 30 Nov 2023 21:14:39 +0200 [thread overview]
Message-ID: <83jzpzaw9s.fsf@gnu.org> (raw)
In-Reply-To: <yplma5qvm5ew.fsf@mnet-mail.de> (message from Raffael Stocker on Thu, 30 Nov 2023 19:28:27 +0100)
> From: Raffael Stocker <r.stocker@mnet-mail.de>
> 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.
next prev parent reply other threads:[~2023-11-30 19:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-29 21:29 bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Raffael Stocker
2023-11-30 7:00 ` Eli Zaretskii
2023-11-30 18:28 ` Raffael Stocker
2023-11-30 19:14 ` Eli Zaretskii [this message]
2023-12-01 17:34 ` Raffael Stocker
2023-12-01 18:12 ` Eli Zaretskii
2023-12-01 21:10 ` Raffael Stocker
2023-12-02 8:03 ` Eli Zaretskii
2023-12-02 14:56 ` Mattias Engdegård
2023-12-02 19:26 ` Raffael Stocker
2023-12-03 10:43 ` Mattias Engdegård
2023-12-03 11:13 ` Raffael Stocker
2023-12-03 11:58 ` Mattias Engdegård
2023-12-05 18:14 ` Raffael Stocker
2023-12-16 9:40 ` Eli Zaretskii
2023-12-18 10:55 ` Mattias Engdegård
2023-12-18 11:39 ` Raffael Stocker
2023-12-19 16:16 ` Mattias Engdegård
2023-12-19 17:09 ` Raffael Stocker
2023-12-19 18:15 ` Mattias Engdegård
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83jzpzaw9s.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=67536@debbugs.gnu.org \
--cc=r.stocker@mnet-mail.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.