[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rx.el sexp regexp syntax

From: Alan Mackenzie
Subject: Re: rx.el sexp regexp syntax
Date: Sun, 27 May 2018 20:16:29 +0000
User-agent: Mutt/1.9.4 (2018-02-28)

Hello, Tom.

On Sun, May 27, 2018 at 10:56:36 -0600, Tom Tromey wrote:
> >>>>> "Alan" == Alan Mackenzie <address@hidden> writes:

> >> Building the automaton is costly.  In C, we build it once and save the
> >> result in a variable so that every regexp match does not rebuild the
> >> automaton each time.

> Alan> Emacs has a (moderately large) cache of regexps, so that building the
> Alan> automatons is done very rarely.  Possibly just once each for each
> Alan> session of Emacs.

> I wonder about both of these statements.

> On the one hand, AFAICT the regex cache is 20 items.  From search.c:

>    #define REGEXP_CACHE_SIZE 20

> That seems pretty small to me, given how prevalent regexps are in elisp.

Hmm.  I must have misremembered.  I thought the cache size was 60, for
some reason.  Now that RAM is measured in gigabytes, we could probably
increase that 20 (if there's any need).

> On the other hand, in the past when I have tried to profile Emacs, I
> haven't seen regexp compilation show up too much.  IIRC I did see regexp
> matching and the GC.  Maybe this just points out the efficacy of the
> cache -- maybe 20 items is plenty.

Maybe.  I just don't know.

> Perhaps the regexp matcher could use some micro-optimizations, like the
> token-threading the bytecode interpreter does.

> Alan> Are you suggesting here building an interpreter in Lisp directly to
> Alan> execute rx expressions?

> It's interesting, IMO, to consider compiling rx (or regexps generally)
> to lisp bytecode.  Perhaps with the JIT, it would boost performance in
> some cases.  (It may be slower, but it's worthwhile to do the
> experiment.)

> For other work in this area see Stefan's lex-parse-re package.  I think
> it includes a regexp matcher in elisp.

I'll need to have a look at that.

> Tom

Alan Mackenzie (Nuremberg, Germany).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]