unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Performance asymmetry with overlays
@ 2003-05-16 23:10 Satyaki Das
  2003-05-17  0:51 ` Luc Teirlinck
  0 siblings, 1 reply; 3+ messages in thread
From: Satyaki Das @ 2003-05-16 23:10 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]


There seems to be an asymmetry in performance when overlays are
used depending on initial cursor position in a buffer. Here is a
test that demonstrates it:

0. Save the attached file as overlay-test.el

1. Start emacs with:
      emacs -q --no-site-file -l overlay-test.el

2. Open a large file. I tried this with the NEWS file by doing:
      C-h n

3. Go to the end of the buffer (with M->) and do:
      M-x overlay-test RET
   It runs very quickly (on my 800MHz Pentium 3 it takes 0.22 sec)

4. Remove the overlays with: M-x overlay-test-reset.

5. Go to the beginning of the buffer and run overlay-test again.
   This time it takes about 71.5 sec!

[I got the times by using elp]

I am running CVS Emacs from yesterday on a Redhat GNU/Linux 9.0
on a Pentium 3. I get similar results with Emacs-21.3.1 built on
the same machine. I also tried on a different Solaris machine
with Emacs-21.2 and got similar results.

I did profile overlay-test. It seems that when cursor is at top of
the buffer initially, make-overlay and forward-line both take much
longer than in the other case.

Can this be improved?

Thanks,
Satyaki


[-- Attachment #2: Test for Overlays --]
[-- Type: text/plain, Size: 484 bytes --]

(defvar overlay-test-string "%")

(defun overlay-test ()
  (interactive)
  (let ((start (point-min))
        (end (point-max))
        ov)
    (goto-char start)
    (beginning-of-line)
    (while (and (not (eobp)) (< (point) end))
      (setq ov (make-overlay (point) (1+ (point))))
      (overlay-put ov 'display overlay-test-string)
      (forward-line))))

(defun overlay-test-reset ()
  (interactive)
  (dolist (ov (overlays-in (point-min) (point-max)))
    (delete-overlay ov)))

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Performance asymmetry with overlays
  2003-05-16 23:10 Performance asymmetry with overlays Satyaki Das
@ 2003-05-17  0:51 ` Luc Teirlinck
  2003-05-17  1:18   ` Satyaki Das
  0 siblings, 1 reply; 3+ messages in thread
From: Luc Teirlinck @ 2003-05-17  0:51 UTC (permalink / raw)
  Cc: emacs-devel

Apparently your particular test runs a lot faster with overlays
centered at point-max.  I do not know whether that is really a general
rule, however.  Somebody who knows more about the internal
implementation of overlays than I do should comment on that.

The folllowing variation on your test contains only one single added
line:

(overlay-recenter (point-max)) 

With this change, execution speed seems to be essentially independent
of the starting position.

(defun overlay-test ()
  (interactive)
  (let ((start (point-min))
        (end (point-max))
        ov)
    (goto-char start)
    (overlay-recenter (point-max))
    (beginning-of-line)
    (while (and (not (eobp)) (< (point) end))
      (setq ov (make-overlay (point) (1+ (point))))
      (overlay-put ov 'display overlay-test-string)
      (forward-line))))

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Performance asymmetry with overlays
  2003-05-17  0:51 ` Luc Teirlinck
@ 2003-05-17  1:18   ` Satyaki Das
  0 siblings, 0 replies; 3+ messages in thread
From: Satyaki Das @ 2003-05-17  1:18 UTC (permalink / raw)
  Cc: emacs-devel

Luc Teirlinck <teirllm@dms.auburn.edu> writes:

> Apparently your particular test runs a lot faster with overlays
> centered at point-max.  I do not know whether that is really a general
> rule, however.  Somebody who knows more about the internal
> implementation of overlays than I do should comment on that.
> 
> The folllowing variation on your test contains only one single added
> line:
> 
> (overlay-recenter (point-max)) 
> 
> With this change, execution speed seems to be essentially independent
> of the starting position.

Thanks, that performs much better! I needed an overlay-recenter in
the other function too. Otherwise that becomes slow.

Satyaki

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-05-17  1:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-16 23:10 Performance asymmetry with overlays Satyaki Das
2003-05-17  0:51 ` Luc Teirlinck
2003-05-17  1:18   ` Satyaki Das

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).