From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Eli Zaretskii <eliz@gnu.org>,
mattiase@acm.org, arstoffel@gmail.com, eller.helmut@gmail.com,
dmcc2@hypnicjerk.ai, pipcet@protonmail.com,
emacs-devel@gnu.org, acorallo@gnu.org, stefankangas@gmail.com
Subject: Re: [PATCH] add compiled regexp primitive lisp object
Date: Tue, 24 Dec 2024 00:37:15 -0500 [thread overview]
Message-ID: <jwvseqdhd2g.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87y106jr4i.fsf@localhost> (Ihor Radchenko's message of "Mon, 23 Dec 2024 16:33:49 +0000")
> Having compiler regexp object exposed to Elisp would open the
> following extra opportunities:
Nitpick: there are various ways to "Add compiled regexp primitive lisp
object", and not all of them would really expose those objects in ways
would allow the following points.
> 1. They could be inspected from Elisp, and hopefully optimized
> better. For now, there is simply no way to detect which parts of
> regexps are slow and which are not.
You can now/already use `re--describe-compiled` to inspect the compiled
regexps used by Emacs's regexp engine.
> 2. They could maybe even be constructed from Elisp, opening
> opportunities for custom regexp compilers that can be tailored to
> specific application needs rather than having to stick to hard-coded
> generic tradeoffs Emacs has to do without knowing the purpose of a
> regexp.
Definitely. And since it would be one in ELisp, there could be dozens
of specialized compilers in ELPA packages to choose from. 🙂
Eli wrote:
> If we can optimize them from Lisp, we should be able to do the same
> in C.
`re_compile_pattern` is not terribly easy to improve. Among other
things because it needs to be fast, single pass, etc...
If regexp objects are exposed in such a way that we can build them from
ELisp and write them to `.elc` files, then anyone can write their own
regexp compiler for their own regexp flavor, which can be as slow as
they like because it won't slow down anyone else.
> If you explain what kind of optimization opportunities you had in
> mind, we could discuss how to implement that. In any case, adding
> APIs for regexp optimizations doesn't require to have compiled regexp
> objects.
If we want to be able to compile regexps to a DFA-style compiled form,
we'll need to extend the regexp bytecode, of course, but it would either
require we implement that compilation in C (which could be a fair bit
of work) or it would require changing `re_compile_pattern` to recognize
new elements in the regexp-string corresponding to those new
bytecode instructions.
I have the impression it would be simpler to expose the bytecode vectors
to ELisp (so as to be able to build them and print+read them) and do the
rest in ELisp. Or course, we'd still want to keep `re_compile_pattern`
to handle the cases where we can't (or can't be bothered to) pre-compile
the regexp and hence where the compilation to bytecode needs to be as
fast as possible.
Stefan
next prev parent reply other threads:[~2024-12-24 5:37 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-30 5:08 [PATCH] add compiled regexp primitive lisp object Danny McClanahan
2024-07-30 13:02 ` Philip Kaludercic
2024-07-31 22:33 ` dmcc2
2024-08-01 1:04 ` Pip Cet
2024-08-04 23:38 ` Danny McClanahan
2024-08-05 3:47 ` dmcc2
2024-08-05 4:39 ` Danny McClanahan
2024-08-05 7:15 ` Danny McClanahan
2024-08-05 17:55 ` Pip Cet
2024-08-06 15:15 ` Danny McClanahan
2024-08-06 15:57 ` Eli Zaretskii
2024-08-07 4:28 ` Danny McClanahan
2024-08-06 18:18 ` Pip Cet
2024-08-06 18:38 ` Eli Zaretskii
2024-08-07 4:23 ` Danny McClanahan
2024-08-07 12:00 ` Eli Zaretskii
2024-08-07 12:43 ` Helmut Eller
2024-08-07 13:40 ` Augusto Stoffel
2024-08-07 15:23 ` Danny McClanahan
2024-08-14 1:32 ` Stefan Monnier
2024-11-26 18:05 ` Danny McClanahan
2024-11-26 18:50 ` Danny McClanahan
2024-12-08 15:24 ` Danny McClanahan
2024-12-09 15:12 ` Stefan Monnier
2024-12-09 15:13 ` Stefan Monnier
2024-12-22 19:14 ` Ihor Radchenko
2024-12-22 19:24 ` Eli Zaretskii
2024-12-22 20:02 ` Ihor Radchenko
2024-12-22 20:20 ` Eli Zaretskii
2024-12-22 20:31 ` Ihor Radchenko
2024-12-23 13:38 ` Björn Bidar
[not found] ` <8634ie60jd.fsf@gnu.org>
2024-12-23 16:33 ` Ihor Radchenko
2024-12-23 16:49 ` Eli Zaretskii
2024-12-23 17:10 ` Ihor Radchenko
2024-12-24 21:16 ` Björn Bidar
2024-12-24 5:37 ` Stefan Monnier [this message]
2024-12-24 9:30 ` Ihor Radchenko
2024-12-24 15:14 ` Stefan Monnier
2024-08-07 15:02 ` Danny McClanahan
2024-08-07 15:23 ` Eli Zaretskii
2024-08-14 1:25 ` Stefan Monnier
2024-08-07 7:59 ` Danny McClanahan
2024-08-06 12:08 ` Eli Zaretskii
2024-08-01 8:30 ` Andrea Corallo
2024-08-01 10:06 ` Gerd Möllmann
2024-08-06 13:47 ` Danny McClanahan
2024-08-06 13:57 ` Danny McClanahan
2024-08-07 7:21 ` Andrea Corallo
2024-08-07 8:27 ` Danny McClanahan
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=jwvseqdhd2g.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=acorallo@gnu.org \
--cc=arstoffel@gmail.com \
--cc=dmcc2@hypnicjerk.ai \
--cc=eliz@gnu.org \
--cc=eller.helmut@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=mattiase@acm.org \
--cc=pipcet@protonmail.com \
--cc=stefankangas@gmail.com \
--cc=yantar92@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 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.