unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Mattias Engdegård" <mattiase@acm.org>
Cc: 63225@debbugs.gnu.org, yantar92@posteo.net
Subject: bug#63225: Compiling regexp patterns (and REGEXP_CACHE_SIZE in search.c)
Date: Tue, 02 May 2023 18:25:18 +0300	[thread overview]
Message-ID: <83sfcen4bl.fsf@gnu.org> (raw)
In-Reply-To: <63882A45-BD02-40D5-92FA-70175267BA3B@acm.org> (message from Mattias Engdegård on Tue, 2 May 2023 16:33:58 +0200)

> Cc: 63225@debbugs.gnu.org
> From: Mattias Engdegård <mattiase@acm.org>
> Date: Tue, 2 May 2023 16:33:58 +0200
> 
> Indeed it sounds like you are suffering from regexp cache thrashing. I'm attaching two patches: one to measure the cache miss rate, and one that allows the regexp cache size to be changed at run time.

Thanks, but the new primitives need to be documented (why do the doc
strings say "internal use only"?), and also we should include the
cache size in the output of memory-report.

> +static void
> +set_regexp_cache_size (int n)
> +{
> +  for (int i = 0; i < regexp_cache_size; i++)
> +    xfree (searchbufs[i].buf.buffer);
> +
> +  size_t bytes = n * sizeof *searchbufs;
> +  searchbufs = xrealloc (searchbufs, bytes);
> +  memset (searchbufs, 0, bytes);
> +  regexp_cache_size = n;
> +

Should this first check that the new size is identical to the old one,
and if so, do nothing?  Come to think of this, do we really need to
realloc if the new size is smaller?  And why zero out the cache when
changing the size?

> +DEFUN ("regexp-cache-size", Fregexp_cache_size, Sregexp_cache_size,
> +       0, 0, 0,
> +       doc: /* Current regexp cache size.  Internal use only.  */)
> +  (void)
> +{
> +  return make_int (regexp_cache_size);
> +}

Since the size of the cache is a fixnum, why not use make_fixnum here?
it's a tad faster.





  reply	other threads:[~2023-05-02 15:25 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-02  7:37 bug#63225: Compiling regexp patterns (and REGEXP_CACHE_SIZE in search.c) Ihor Radchenko
2023-05-02 14:33 ` Mattias Engdegård
2023-05-02 15:25   ` Eli Zaretskii [this message]
2023-05-02 15:28     ` Mattias Engdegård
2023-05-02 17:30       ` Eli Zaretskii
2023-05-02 17:58         ` Ihor Radchenko
2023-05-02 16:14   ` Ihor Radchenko
2023-05-02 21:00     ` Mattias Engdegård
2023-05-02 21:21       ` Ihor Radchenko
2023-05-03  8:39         ` Mattias Engdegård
2023-05-03  9:36           ` Ihor Radchenko
2023-05-03 13:59             ` Mattias Engdegård
2023-05-03 15:05               ` Ihor Radchenko
2023-05-03 15:20                 ` Mattias Engdegård
2023-05-03 16:02                   ` Ihor Radchenko
2023-05-04  9:24                     ` Mattias Engdegård
2023-05-05 10:31                       ` Ihor Radchenko
2023-05-05 16:26                         ` Mattias Engdegård
2023-05-06 13:38                           ` Ihor Radchenko
2023-05-07 10:32                             ` Mattias Engdegård
2023-05-08 11:58                               ` Ihor Radchenko
2023-05-08 18:21                                 ` Mattias Engdegård
2023-05-08 19:38                                   ` Ihor Radchenko
2023-05-08 19:53                                     ` Mattias Engdegård
2023-05-09  8:36                                       ` bug#63225: Using char table-based finite-state machines as a replacement for re-search-forward (was: bug#63225: Compiling regexp patterns (and REGEXP_CACHE_SIZE in search.c)) Ihor Radchenko
2023-05-09 12:02                                       ` bug#63225: Compiling regexp patterns (and REGEXP_CACHE_SIZE in search.c) Ihor Radchenko
2023-05-09 15:05                                         ` Mattias Engdegård
2023-05-09 15:56                                           ` Ihor Radchenko
2023-05-09 15:57                                             ` Mattias Engdegård
2023-05-07 12:45                           ` Mattias Engdegård
2023-05-08 13:56                             ` Ihor Radchenko
2023-05-08 19:32                               ` Mattias Engdegård
2023-05-08 19:44                                 ` Ihor Radchenko
2023-05-04 12:58               ` Ihor Radchenko
2023-05-02 23:36   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=83sfcen4bl.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=63225@debbugs.gnu.org \
    --cc=mattiase@acm.org \
    --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 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).