unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Stefan Monnier" <monnier+gnu/emacs/pretest@cs.yale.edu>
Cc: Alan Mackenzie <acm@muc.de>,
	monnier+gnu/emacs/pretest@cs.yale.edu, bug-cc-mode@gnu.org,
	emacs-devel@gnu.org
Subject: Re: Advising in cc-awk.el and namespace
Date: Fri, 11 Jul 2003 13:35:36 -0400	[thread overview]
Message-ID: <200307111735.h6BHZaZO023544@rum.cs.yale.edu> (raw)
In-Reply-To: E19b1aj-00053D-JK@fencepost.gnu.org

>     load a large file (say, ..../emacs/src/keyboard.c) wait for jit-lock to
>     finish fontifying it in the background, then make a small change near the
>     beginning of this file, needlessly refontifying ~320kBytes consumes ~55%
>     of the CPU's power for 3½ minutes.
> 
> Why does a small change near the beginning refontify the whole file?
> I suppose there are some small changes that might legitimately do so,
> but I would not expect most small changes to do so.  What's up?

Because in general, it might be necessary and font-lock does
not try to be clever here.

Basically syntactic-fontification (fontification of comments and string)
depends on the output of `syntax-ppss' and because font-lock-keyword
rules are order-dependent (they typically are only applied if there isn't
already some fontification at point, so that keywords aren't highlighted
inside strings), after redoing syntactic-fontification, keywords
fontification needs to be redone as well.

A change at pos N potentially changes the output of syntax-ppss for
all pos>N, so jit-lock just refontifies everything (in the background
with jit-lock-stealth-*).  Of course, in practice the output of
syntax-ppss is generally not changed for all pos>N but only for N<pos<M
(or sometimes it is changed for all pos>N but the change is marginal or
irrelevant and will not influence the result of font-locking), so we could
be more clever, but we would need to cache the parse-state-before-change
so we can compare it to the parse-state-after-change so we can stop when
they are equal again.  It might be worth the effort, but nobody has
bothered coding it up yet.  Turning off jit-lock-stealth-* is a simpler
workaround for the CPU-power-wasting problem.


	Stefan



-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps1


  reply	other threads:[~2003-07-11 17:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200307091720.h69HKLEN015169@rum.cs.yale.edu>
2003-07-10 19:31 ` Advising in cc-awk.el and namespace Alan Mackenzie
2003-07-11 15:12   ` Stefan Monnier
2003-07-16 19:34     ` Martin Stjernholm
2003-07-11 17:21   ` Richard Stallman
2003-07-11 17:35     ` Stefan Monnier [this message]
2003-07-12  5:32       ` Richard Stallman
2003-07-16 15:28         ` Stefan Monnier
2003-07-17 23:55           ` Richard 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

  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=200307111735.h6BHZaZO023544@rum.cs.yale.edu \
    --to=monnier+gnu/emacs/pretest@cs.yale.edu \
    --cc=acm@muc.de \
    --cc=bug-cc-mode@gnu.org \
    --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).