emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: open large file with C code: is it realy should be so slow?


From: Alan Mackenzie
Subject: Re: open large file with C code: is it realy should be so slow?
Date: Sun, 4 Jan 2009 23:31:14 +0000
User-agent: Mutt/1.5.9i

Hi, Dave,

I'm actually working on this bug at the moment.  With the Yuletide break,
and so on, I've kind of lost the thread a bit and I got bogged down in
the complexities of the code.  I should have got back to you sooner;
sorry!

On Mon, Jan 05, 2009 at 01:07:18AM +0300, Dave Milter wrote:
> On Mon, Dec 1, 2008 at 3:37 PM, Alan Mackenzie <address@hidden> wrote:

> > On Mon, Dec 01, 2008 at 01:01:08PM +0300, Dave Milter wrote:
> >> I have problem with emacs responsibility,
> >> I work with large enough C header files,
> >> and when I want to scroll it using mouse's wheel or
> >> page (up|down) keys emacs stop react on any keys, like (ctrl+g),
> >> and eats 100% of CPU's time during long period,
> >> I wonder is this a bug, or expected behaviour?

> > It's a bug.

> > Although C Mode works "properly" here, it doesn't seem to be tuned
> > very well for files like this one (At91SAM9253_inc.h), which contain
> > a lot of #defines and comments and nothing else.

> I made some more testing (to find out problem in "file", or in "large"),
> because of really want to see this bug fixed,

It will be fixed, hopefully within the next few days.  It's too serious a
bug not to fix.

> I see the same behaviour on file created by

> for ((i=0;i<500;++i)); do echo "extern void f${i}(int a${i});"; done

Yes.  The CC Mode function which is to blame is `c-parse-state'.  It
maintains a "cache" of (essentially) brace pairs, using the positions of
these braces to scan from.  In a "brace desert", it scans from the
beginning of the buffer, sometimes many times per (scroll) command, and
this is why it is so slow.

To see this, create an alternative file like this:

    for ((i=0;i<500;++i)); do echo "extern void f${i}(int a${i}) {}"; done
                                                                 ^^

Scrolling in this file will be instantaneous, as it should be.

> emacs from cvs and emacs 22 show the same behaviour -
> eating 100% of cpu, if make fast scrolling.

Yes.

[ .... ]

> In fact, with small files, for example the same script but 5000 -> 500,
> I see the same situation, but after eating cpu during some period,
> it never eating it after, and all works smoothly,
> while with big files it eats it every fast scroll.

If you profile the stuff in cc-engine.el, you'll see c-parse-state right
at the top.

-- 
Alan Mackenzie (Nuremberg, Germany).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]