From: storm@cua.dk (Kim F. Storm)
Cc: rms@gnu.org, emacs-devel@gnu.org
Subject: Re: Display slowness that is painful
Date: Thu, 02 Feb 2006 12:33:26 +0100 [thread overview]
Message-ID: <m3d5i6m1vd.fsf@kfs-l.imdomain.dk> (raw)
In-Reply-To: <87mzhaqp7p.fsf@stupidchicken.com> (Chong Yidong's message of "Thu, 02 Feb 2006 00:55:38 -0500")
Chong Yidong <cyd@stupidchicken.com> writes:
> "Richard M. Stallman" <rms@gnu.org> writes:
>
>> This is *really* not the time to make changes in redisplay.
>>
>> Yes it is. Even if we had started the pretest already,
>> we would fix this bug. Or what are pretests for?
I don't know -- it's been so long since I participated in one that I
have forgot :-)
> Managers of successful software projects often make the conscious
> choice to postphone resolving bugs whose "fixes" can introduce even
> more serious bugs while conferring limited benefits. (And they seem
> to be able to actually make releases...)
Yes, that is what "management" is all about -- making decisions when
"enough is enough".
> In this particular case, having looked through the relevant redisplay
> code, I don't see any apparent code stupidity going on. It's simply
> the case that, in this file, the first "newline" takes place 340,000
> characters in.
Good catch!!
That can definitely cause problems for redisplay as it does search for
line beginnings/ends quite a lot, but usually the penalty is neglible.
> The normally negligible delay from displaying glyphs
> in octal format (v.s. unibyte-display-via-language-environment) is
> magnified by this amount. The redisplay engine has to scroll through
> the entire "line" to check for overlays, text properties, etc., and
> this seems to be unavoidable.
I tried to create two files like this:
emacs -q
C-x C-f file1.txt RET RET C-p ESC 3 4 0 0 0 0 x
C-x C-f file2.txt RET RET C-p ESC 3 4 0 0 0 0 C-q 2 1 2 RET
and indeed doing C-p C-n (or C-a C-e) in the second buffer is
significantly slower than in the first buffer.
Ok, one might expect it to be 4 times slower, but it is (feels) much
slower than that (perhaps 8 times slower).
It seems to be because it needs to merge_face with the escape glyph
for each character -- and that takes extra time. Below is a patch to
speed up the processing for this specific part of the problem. With
the patch, redisplay time for file2 seems to be approx 4 x redisplay time
for file1.
*** xdisp.c 24 Jan 2006 09:30:15 +0100 1.1073
--- xdisp.c 02 Feb 2006 11:33:04 +0100
***************
*** 5329,5334 ****
--- 5329,5338 ----
display element from the current position of IT. Value is zero if
end of buffer (or C string) is reached. */
+ static struct frame *last_escape_glyph_frame = NULL;
+ static unsigned last_escape_glyph_face_id = (1 << FACE_ID_BITS);
+ static int last_escape_glyph_merged_face_id = 0;
+
int
get_next_display_element (it)
struct it *it;
***************
*** 5445,5455 ****
--- 5449,5467 ----
face_id = merge_faces (it->f, Qt, lface_id,
it->face_id);
}
+ else if (it->f == last_escape_glyph_frame
+ && it->face_id == last_escape_glyph_face_id)
+ {
+ face_id = last_escape_glyph_merged_face_id;
+ }
else
{
/* Merge the escape-glyph face into the current face. */
face_id = merge_faces (it->f, Qescape_glyph, 0,
it->face_id);
+ last_escape_glyph_frame = it->f;
+ last_escape_glyph_face_id = it->face_id;
+ last_escape_glyph_merged_face_id = face_id;
}
XSETINT (it->ctl_chars[0], g);
***************
*** 5496,5506 ****
--- 5508,5526 ----
face_id = merge_faces (it->f, Qt, lface_id,
it->face_id);
}
+ else if (it->f == last_escape_glyph_frame
+ && it->face_id == last_escape_glyph_face_id)
+ {
+ face_id = last_escape_glyph_merged_face_id;
+ }
else
{
/* Merge the escape-glyph face into the current face. */
face_id = merge_faces (it->f, Qescape_glyph, 0,
it->face_id);
+ last_escape_glyph_frame = it->f;
+ last_escape_glyph_face_id = it->face_id;
+ last_escape_glyph_merged_face_id = face_id;
}
/* Handle soft hyphens in the mode where they only get
***************
*** 10545,10550 ****
--- 10565,10572 ----
retry:
pause = 0;
reconsider_clip_changes (w, current_buffer);
+ last_escape_glyph_frame = NULL;
+ last_escape_glyph_face_id = (1 << FACE_ID_BITS);
/* If new fonts have been loaded that make a glyph matrix adjustment
necessary, do it. */
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
next prev parent reply other threads:[~2006-02-02 11:33 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-27 22:31 Display slowness that is painful Richard Stallman
2006-01-31 5:10 ` Chong Yidong
2006-01-31 23:09 ` Richard M. Stallman
2006-02-01 1:25 ` Chong Yidong
2006-02-01 2:59 ` Stefan Monnier
2006-02-01 4:52 ` Chong Yidong
2006-02-01 5:15 ` Miles Bader
2006-02-02 6:02 ` Chong Yidong
2006-02-02 4:15 ` Richard M. Stallman
2006-02-02 4:50 ` Chong Yidong
2006-02-01 10:43 ` Andreas Schwab
2006-02-03 2:06 ` Kenichi Handa
2006-02-03 10:15 ` Andreas Schwab
2006-02-03 12:01 ` Kenichi Handa
2006-02-03 13:08 ` Andreas Schwab
2006-02-03 19:17 ` Eli Zaretskii
2006-02-03 23:34 ` Andreas Schwab
2006-02-07 1:41 ` Kenichi Handa
2006-02-02 4:16 ` Richard M. Stallman
2006-02-02 5:55 ` Chong Yidong
2006-02-02 6:12 ` Chong Yidong
2006-02-02 9:50 ` David Kastrup
2006-02-02 14:02 ` Stefan Monnier
2006-02-03 23:43 ` Richard M. Stallman
2006-02-02 11:33 ` Kim F. Storm [this message]
2006-02-03 1:50 ` Kenichi Handa
2006-02-03 9:55 ` Kim F. Storm
2006-02-04 18:27 ` Richard M. Stallman
2006-02-03 5:04 ` Richard M. Stallman
2006-02-03 10:00 ` Kim F. Storm
2006-02-03 23:01 ` Stefan Monnier
2006-02-05 0:16 ` Kim F. Storm
2006-02-04 18:27 ` Richard M. Stallman
2006-02-04 21:18 ` Kim F. Storm
2006-02-05 1:59 ` Stefan Monnier
2006-02-06 2:06 ` Richard M. Stallman
2006-02-06 8:22 ` Kim F. Storm
2006-02-07 6:06 ` Richard M. Stallman
2006-02-07 9:14 ` Kim F. Storm
2006-02-08 19:03 ` Richard M. Stallman
2006-02-09 9:20 ` Kim F. Storm
2006-02-09 20:10 ` Eli Zaretskii
2006-02-13 4:40 ` Richard M. Stallman
2006-02-13 4:40 ` Richard M. Stallman
2006-02-06 2:06 ` Richard M. Stallman
2006-02-06 8:19 ` Kim F. Storm
2006-02-06 8:45 ` Miles Bader
2006-02-06 10:34 ` Kim F. Storm
2006-02-07 6:06 ` Richard M. Stallman
2006-02-05 0:30 ` Miles Bader
2006-02-05 0:44 ` Kim F. Storm
2006-02-02 14:00 ` Stefan Monnier
2006-02-01 10:51 ` Andreas Schwab
2006-02-01 23:10 ` Chong Yidong
2006-02-02 4:16 ` Richard M. Stallman
2006-02-02 10:37 ` Andreas Schwab
-- strict thread matches above, loose matches on Subject: below --
2006-01-19 17:43 Richard Stallman
2006-01-31 5:07 ` Evil Boris
2006-01-11 18:58 Richard M. Stallman
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=m3d5i6m1vd.fsf@kfs-l.imdomain.dk \
--to=storm@cua.dk \
--cc=emacs-devel@gnu.org \
--cc=rms@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 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.