unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Andreas Politz <politza@hochschule-trier.de>
To: emacs-devel@gnu.org
Subject: Re: Overlays as an AA-tree
Date: Mon, 13 Feb 2017 04:44:05 +0100	[thread overview]
Message-ID: <877f4uah6i.fsf@hochschule-trier.de> (raw)
In-Reply-To: <87efz7n0g5.fsf@fastmail.com> (Joakim Jalap's message of "Thu, 09 Feb 2017 11:05:46 +0100")

So,

 I've been working on this thing and below are my preliminary
findings, so to speak.  The code can be found here [1].  There is a
file etc/noverlay.org in there, containing some notes and pointing to
some other files.

I developed some performance tests, which for the most part are very
bare-bones and test single functions only in a constrained environment.
Following are some numbers, a description of the test-functions and an
attempt to make sense of the results.

====================================================================================
                                        list                          tree
n=1000                          n        8n      64n           n       8n     64n
                               ----------------------        ----------------------
perf-make-overlay              0.00	0.01	0.10         0.00     0.01    0.08
perf-make-overlay-continuous   0.00	0.01	0.10         0.00     0.01    0.08
perf-make-overlay-scatter      0.00	0.22	50.76        0.00     0.01    0.16
perf-delete-overlay            0.01	0.69	74.54        0.00     0.00    0.01
perf-delete-overlay-continuous 0.01	0.52	54.10        0.00     0.00    0.01
perf-delete-overlay-scatter    0.00	0.31	37.43        0.00     0.00    0.01
perf-overlays-at               0.00	0.44	88.08        0.00     0.02    0.32
perf-overlays-in               0.00	0.46	90.91        0.00     0.05    0.76
perf-insert-before             0.01	0.11	1.49         0.00     0.00    0.00
perf-insert-after              0.01	0.09	1.12         0.00     0.00    0.00
perf-insert-scatter            0.02	1.25	186.64       0.00     0.02    0.31
perf-delete-before             0.02	1.80	298.44       0.04     3.02    468.16
perf-delete-after              0.02	1.77	299.54       0.03     2.24    309.39
perf-delete-scatter            0.02	1.64	277.82       0.00     0.05    1.09
                               -----------------------       -----------------------

perf-flycheck                        5.01* / 23.83                    4.88
perf-flycheck-display                  15.03*                         7.64

====================================================================================
                                                             * with overlay-recenter

* perf-(make|delete)-overlay
  (Make|delete) N overlays in an empty buffer.
* perf-(make|delete)-overlay-continuous
  (Make|delete) N consecutive overlays of length 1 in a buffer of size
  N.
* perf-(make|delete)-overlay-scatter
  (Make|delete) N randomly chosen overlays of length 24 in a buffer of
  size N.
* perf-overlays-(at|in)
  Extract overlays (at|in) every buffer (position|range of length 24) from
  1 to point-max.
* perf-insert-(before|after|scatter)
  Insert N overlays randomly in a N sized buffer and insert N
  character at (point-min|point-max|randomly).
* perf-delete-(before|after|scatter)
  Same as above, but delete characters.
* perf-flycheck
  Perform a flycheck on a notorious file[2] with about 15000 errors.
  The second lower number for the master branch results from an
  inserted overlay-recenter into the flycheck code.  These numbers
  vary greatly for the list implementation.
* perf-flycheck-display
  Same as above, then scroll the buffer once completely down and up
  again, while redisplaying after every scroll step.


Since the current overlay implementation is very sensitive to its
center position, I chose the most favorable of either point-min or
-max in every non-random test.  Furthermore, I measured only the
function itself, e.g. perf-delete-overlay does not include the time to
create the overlays.  Also I garbage-collected before every test.  All
overlays were created with default advance.

I think we see what one should expect: The list implementation
performs decent, if the number of overlays stays reasonable or it is
allowed to insert/delete from the list start.  Only when the numbers
get close to 100.000 and it needs to perform random-access operations,
are we seeing a serious performance degradation.

On the other hand, the tree stays solid even with large numbers,
except for two notable cases: Continuously deleting at the beginning
or end of the buffer.  In this case the overlays sooner or later all
linger at the same position and the tree slowly turns into a black
soup -- effectively a unordered, awkward to traverse list.

Recentering the list's center in the flycheck test shows the
difference between the optimal linear and the worst case quadratic
complexity of this implementation (when adding n elements).  But I
this "magic trick" (using overlay-recenter) only works, if the buffer
does not contain a significant amount of overlays to begin with.

The final test seems to indicate that redisplay has an effect on this,
probably due to the fact that it in some cases recenters the lists.

-ap

[1] https://github.com/politza/emacs-noverlay
[2] https://github.com/flycheck/flycheck/issues/635



  parent reply	other threads:[~2017-02-13  3:44 UTC|newest]

Thread overview: 110+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20 10:32 Overlays as an AA-tree Joakim Jalap
2016-09-20 12:14 ` Clément Pit--Claudel
2016-09-20 12:43 ` Lars Ingebrigtsen
2016-09-20 16:19   ` Joakim Jalap
2016-09-20 23:19   ` Richard Stallman
2016-09-20 14:40 ` Eli Zaretskii
2016-09-20 17:13   ` Joakim Jalap
2016-09-21 16:14     ` Eli Zaretskii
2016-09-22 10:35       ` Joakim Jalap
2016-09-22 12:24         ` Stefan Monnier
2016-09-21 14:52 ` Stefan Monnier
2016-09-21 15:58   ` Eli Zaretskii
2016-09-21 16:24     ` Stefan Monnier
2016-09-21 16:43       ` Eli Zaretskii
2016-09-21 18:41         ` Stefan Monnier
2016-09-21 19:28           ` Eli Zaretskii
2016-09-22 10:35   ` Joakim Jalap
2016-09-22 12:17     ` Stefan Monnier
2016-09-22 20:11       ` Joakim Jalap
2016-09-23  1:29         ` Stefan Monnier
2016-09-27  6:26           ` Joakim Jalap
2016-09-27 11:50             ` Stefan Monnier
2016-09-27 14:38             ` Eli Zaretskii
2016-09-27 16:07               ` Joakim Jalap
2016-11-21 17:32                 ` Clément Pit--Claudel
2016-11-22  8:09                   ` Joakim Jalap
2016-11-22 13:44                     ` Stefan Monnier
2016-11-23  6:58                       ` Joakim Jalap
2016-11-22 13:44                     ` Clément Pit--Claudel
2016-11-22 13:55                       ` Evgeny Roubinchtein
2016-11-23  7:16                         ` Joakim Jalap
2016-11-23 15:42                           ` Eli Zaretskii
2016-11-23 16:06                             ` Stefan Monnier
2016-11-24 18:33                               ` Evgeny Roubinchtein
2016-11-23  7:13                       ` Joakim Jalap
2017-02-03  8:49 ` Andreas Politz
2017-02-03  9:13   ` Eli Zaretskii
2017-02-03 10:24     ` Andreas Politz
2017-02-03 11:33   ` Joakim Jalap
2017-02-03 12:44     ` Andreas Politz
2017-02-03 14:11       ` Joakim Jalap
2017-02-03 15:02         ` Andreas Politz
2017-02-03 15:23           ` Joakim Jalap
2017-02-03 15:54             ` Andreas Politz
2017-02-04 21:22       ` Stefan Monnier
2017-02-04 23:10         ` Andreas Politz
2017-02-06  9:56           ` Joakim Jalap
2017-02-06 11:33             ` Andreas Politz
2017-02-06 15:33               ` Joakim Jalap
2017-02-06 15:46                 ` Stefan Monnier
2017-02-06 16:52                   ` Joakim Jalap
2017-02-06 17:34                     ` Stefan Monnier
2017-02-06 17:32                 ` Andreas Politz
2017-02-07 12:35               ` Andreas Politz
2017-02-07 14:46                 ` Joakim Jalap
2017-02-07 22:00                 ` Andreas Politz
2017-02-08  0:36                   ` Andreas Politz
2017-02-08  6:53                     ` Joakim Jalap
2017-02-08  7:34                       ` Andreas Politz
2017-02-08  8:18                         ` Joakim Jalap
2017-02-08  8:44                           ` Andreas Politz
2017-02-08 16:34                           ` Andreas Politz
2017-02-08 17:38                         ` Eli Zaretskii
2017-02-08 13:04                   ` Stefan Monnier
2017-02-08 22:27                     ` Andreas Politz
2017-02-08 22:34                       ` Stefan Monnier
2017-02-09  9:34                         ` Andreas Politz
2017-02-09 10:05                           ` Joakim Jalap
2017-02-09 10:19                             ` Andreas Politz
2017-02-13  3:44                             ` Andreas Politz [this message]
2017-02-13  6:11                               ` Eli Zaretskii
2017-02-13  9:04                                 ` Andreas Politz
2017-02-13 14:36                                   ` Eli Zaretskii
2017-02-14 10:07                                     ` Andreas Politz
2017-02-17  4:58                                 ` Andreas Politz
2017-02-17  7:12                                   ` Eli Zaretskii
2017-02-19 22:39                                     ` Andreas Politz
2017-02-19 23:10                                       ` Stefan Monnier
2017-02-19 23:44                                         ` Andreas Politz
2017-02-20 15:34                                       ` Eli Zaretskii
2017-02-21  6:56                                         ` Andreas Politz
2017-02-21 15:11                                           ` Stefan Monnier
2017-02-21 18:26                                             ` Andreas Politz
2017-02-21 19:18                                               ` Stefan Monnier
2017-02-21 23:36                                                 ` Andreas Politz
2017-02-24  8:43                                                 ` Andreas Politz
2017-04-08 13:28                                                   ` Clément Pit-Claudel
2017-05-03 19:20                                                     ` Andreas Politz
2017-05-03 19:40                                                       ` Stefan Monnier
2017-05-05 20:39                                                         ` Andreas Politz
2017-05-04  0:54                                                       ` Clément Pit-Claudel
2017-05-05 20:10                                                         ` Andreas Politz
2017-05-05 22:22                                                           ` Clément Pit-Claudel
2017-05-06  8:05                                                             ` Andreas Politz
2017-05-04 14:21                                                       ` Eli Zaretskii
2017-05-05 20:08                                                         ` Andreas Politz
2017-05-05 21:41                                                           ` Eli Zaretskii
2017-09-24 13:09                                                         ` Clément Pit-Claudel
2017-10-04  8:17                                                           ` Andreas Politz
2017-10-04  9:22                                                             ` Eli Zaretskii
2017-10-04 20:36                                                               ` Andreas Politz
2017-02-14  0:45                               ` Richard Stallman
2017-02-14  8:32                                 ` Andreas Politz
2017-02-06 13:51             ` Stefan Monnier
2017-02-06 14:26               ` Andreas Politz
2017-02-06 15:06                 ` Stefan Monnier
2017-02-06 15:40               ` Joakim Jalap
2017-02-06 16:24                 ` Clément Pit-Claudel
2017-02-03 13:55   ` Stefan Monnier
2017-02-03 15:14     ` Andreas Politz

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=877f4uah6i.fsf@hochschule-trier.de \
    --to=politza@hochschule-trier.de \
    --cc=emacs-devel@gnu.org \
    /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).