all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: emacs-devel@gnu.org
Subject: Re: Markers in a gap array
Date: Thu, 04 Jul 2024 18:24:47 -0400	[thread overview]
Message-ID: <jwvikxk24d3.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <jwvzfqx0wde.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Thu, 04 Jul 2024 16:11:28 -0400")

BTW, I just pushed to `scratch/gl-state-bytepos` an orthogonal patch
which intends to reduce the use of `bytepos_to_charpos` by changing
the `gl_state` cache so it keeps track of the byteposition of the
boundaries of the current "chunk of `syntax-table` property".

This way RE_UPDATE_SYNTAX_TABLE can take a bytepos rather than an charpos
and convert it to charpos only when moving into a different "chunk of
`syntax-table` property".

On that previous benchmark, it works wonderfully (the implementation of
markers has basically no impact any more in that benchmark):

  | test                   | non-gc avg (s) | gc avg (s) | gcs avg | tot avg (s) | tot avg err (s) |
  |------------------------+----------------+------------+---------+-------------+-----------------|
  | bytechar               |           6.25 |       0.00 |       0 |        6.25 |            0.85 |
  | bytechar-100k          |           6.41 |       0.00 |       0 |        6.41 |            0.65 |
  | bytechar-100k-nolookup |           6.61 |       0.00 |       0 |        6.61 |            0.17 |
  | bytechar-100k-random   |           8.63 |       0.00 |       0 |        8.63 |            0.06 |
  | bytechar-100k-rev      |           7.64 |       0.00 |       0 |        7.64 |            1.48 |
  | bytechar-10k-random    |           6.79 |       0.00 |       0 |        6.79 |            0.10 |
  | bytechar-1k-random     |           6.64 |       0.00 |       0 |        6.64 |            0.15 |
  | bytechar-nolookup      |           6.63 |       0.00 |       0 |        6.63 |            0.23 |
  |------------------------+----------------+------------+---------+-------------+-----------------|
  | total                  |          55.61 |       0.00 |       0 |       55.61 |            1.86 |

Of course, that's the ideal case: that buffer has no `syntax-table` text
properties, so there's only one chunk.  In buffers with many uses of the
`syntax-table` text property, the patch may end up slowing things down
because the update from one chunk to another requires not just
a bytepos->charpos but also two additional charpos->bytepos conversions.

Still, I suspect it will usually be beneficial (the cost of going from
one chunk to another is itself significant so the extra charpos->bytepos
conversions should not slow it down unduly).

The patch has a significant FIXME that needs invesitgating (it passes
all tests, but I'm not sure it's doing the right thing).


        Stefan




  parent reply	other threads:[~2024-07-04 22:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-04  4:59 Markers in a gap array Stefan Monnier
2024-07-04 10:24 ` Ihor Radchenko
2024-07-04 13:16   ` Stefan Monnier
2024-07-04 14:30     ` Ihor Radchenko
2024-07-04 20:11       ` Stefan Monnier
2024-07-04 20:34         ` Pip Cet
2024-07-04 20:42           ` Stefan Monnier
2024-07-17 16:48             ` Helmut Eller
2024-07-18 20:46               ` Stefan Monnier
2024-07-26 19:48                 ` Helmut Eller
2024-08-05 19:54                   ` MPS: marker-vector (was: Markers in a gap array) Helmut Eller
2024-08-05 21:14                     ` MPS: marker-vector Pip Cet
2024-08-06  6:28                       ` Helmut Eller
2024-08-06  6:51                         ` Gerd Möllmann
2024-08-06 14:36                         ` Pip Cet
2024-08-06 16:15                           ` Helmut Eller
2024-08-06  3:59                     ` Gerd Möllmann
2024-08-06  6:02                       ` Helmut Eller
2024-07-04 22:24         ` Stefan Monnier [this message]
2024-07-07 12:31         ` Markers in a gap array Ihor Radchenko
2024-07-07 13:09         ` Konstantin Kharlamov

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=jwvikxk24d3.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.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 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.