From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Native compilation of Keyboard Macros Date: Fri, 16 Sep 2022 15:27:18 -0400 Message-ID: References: <878rmj408c.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12789"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: emacs-devel@gnu.org, Andrea Corallo To: Philip Kaludercic Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 16 21:28:58 2022 Return-path: Envelope-to: ged-emacs-devel@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 1oZH1G-00037U-0U for ged-emacs-devel@m.gmane-mx.org; Fri, 16 Sep 2022 21:28:58 +0200 Original-Received: from localhost ([::1]:40062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oZH1E-0002bc-P7 for ged-emacs-devel@m.gmane-mx.org; Fri, 16 Sep 2022 15:28:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oZGzl-0001lp-N3 for emacs-devel@gnu.org; Fri, 16 Sep 2022 15:27:25 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:45672) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oZGzi-0003uz-VO for emacs-devel@gnu.org; Fri, 16 Sep 2022 15:27:24 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 610C8807C3; Fri, 16 Sep 2022 15:27:21 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id DA92580626; Fri, 16 Sep 2022 15:27:19 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1663356439; bh=QTTDWDz7vHcekD6aeL/NIMEEfu8WaeEPV4YDTJ3ytVU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=X6C7gaRXdm64+BguG4phPq6JGtGBv7Q71Gh/tmzsldfrvI1VA4wD0x9850rvscIEi tz0X+iIgAlPp2C/jItDFP188n62EReHpPP7EU2TE4TUJI3HhdWtto3Ek8ajkMCMEka FFr55fLvi9MNbyzJCpCVkeN5EVRHW6x60RCl/JKW0sH8c+tvx1O6Y8L0c10yEV9q7Q 8mwJCG/yfJEK2QV8fpuugTAcMoGAcjKWCJftm19Y/e+BiYdFss5tO+uAXCh61u96qT U/D5LdFskC8o38dff0XgfFspv3AjUi8wytjkB0YJDfd8bVWiFe730Tv3ZA4kufPM8s EWRYGgLTDnPQw== Original-Received: from alfajor (unknown [45.44.229.252]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id AE492120977; Fri, 16 Sep 2022 15:27:19 -0400 (EDT) In-Reply-To: <878rmj408c.fsf@posteo.net> (Philip Kaludercic's message of "Fri, 16 Sep 2022 18:56:19 +0000") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:295502 Archived-At: 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