From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Philip Kaludercic <philipk@posteo.net>
Cc: emacs-devel@gnu.org, Andrea Corallo <akrl@sdf.org>
Subject: Re: Native compilation of Keyboard Macros
Date: Fri, 16 Sep 2022 15:27:18 -0400 [thread overview]
Message-ID: <jwvleqjrv8p.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <878rmj408c.fsf@posteo.net> (Philip Kaludercic's message of "Fri, 16 Sep 2022 18:56:19 +0000")
Philip Kaludercic [2022-09-16 18:56:19] wrote:
> Is it possible to use native compilation to speed up the execution of
> keyboard macros (or is this already being done)? I think that there are
> certain situations where a macro is executed many times over (C-x C-k r,
> C-0 C-x e) that can slow down Emacs noticeably, where JITing could help.
I think it's somewhere between difficult and impossible.
The problem is not in the *native* part but in the transformation of the
keyboard macro into code: a keyboard macro is defined as a sequence of
events, and each one of those events can cause execution of a different
command every time it's repeated.
Also, I think that if `C-0 C-x e` is too slow, it's usually either:
- The few commands that are executed just take a lot of time
(native-compilation of those commands can help but that's not specific
to the case where they're run via a keyboard macro).
- The `C-x 0 C-x e` looping itself is costly, but most of that is
execution of the repl (the lookup through keymaps, the pre/post
command hooks, processing `interactive`, etc...) most of which is
already coded in C. In that case, turning the keyboard macro into
"plain" ELisp code would bring a significant performance increase,
regardless if it's (native) compiled, but it's almost impossible to do
in general.
So, I think you should focus on the problem of turning a keyboard macro
into code. We know it's impossible in general, so it has to be
"user-visible" (i.e. the user specifically asks for it and is made aware
that the result is a chunk of code which will not always run the same
commands as the keyboard macro).
You could have a "run kmacro and turn *this* execution into ELisp code".
IIUC some people tried to do that already, but I can't remember where
I saw that and my search-fu is weak right now.
Stefan
next prev parent reply other threads:[~2022-09-16 19:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-16 18:56 Native compilation of Keyboard Macros Philip Kaludercic
2022-09-16 19:27 ` Stefan Monnier [this message]
2022-09-17 17:52 ` Juri Linkov
2022-09-17 18:26 ` Philip Kaludercic
2022-09-17 18:40 ` Juri Linkov
2022-09-17 20:00 ` Philip Kaludercic
2022-09-18 3:12 ` Stefan Monnier
2022-09-18 5:02 ` Visuwesh
2022-09-18 13:46 ` Stefan Monnier
2022-09-16 19:54 ` Óscar Fuentes
2022-09-17 14:49 ` Philip Kaludercic
2022-09-17 15:33 ` Óscar Fuentes
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvleqjrv8p.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=akrl@sdf.org \
--cc=emacs-devel@gnu.org \
--cc=philipk@posteo.net \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).