all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* c-mode eats resources?
@ 2006-02-18 21:07 Paul Pogonyshev
  2006-02-18 22:40 ` Chong Yidong
                   ` (8 more replies)
  0 siblings, 9 replies; 17+ messages in thread
From: Paul Pogonyshev @ 2006-02-18 21:07 UTC (permalink / raw)


Apparently, C mode constantly uses processor time even nothing is
done in the buffer.  E.g. if I open a C file in Emacs and go to a
different desktop and start `top' there, it shows Emacs in the
first few lines with 3--7% usage of CPU.  This cannot be right.
Can anybody reproduce this?

Paul

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

* Re: c-mode eats resources?
  2006-02-18 21:07 c-mode eats resources? Paul Pogonyshev
@ 2006-02-18 22:40 ` Chong Yidong
  2006-02-18 23:12   ` Paul Pogonyshev
  2006-02-18 22:47 ` Lennart Borgman
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Chong Yidong @ 2006-02-18 22:40 UTC (permalink / raw)
  Cc: emacs-devel

Paul Pogonyshev <pogonyshev@gmx.net> writes:

> Apparently, C mode constantly uses processor time even nothing is
> done in the buffer.  E.g. if I open a C file in Emacs and go to a
> different desktop and start `top' there, it shows Emacs in the
> first few lines with 3--7% usage of CPU.  This cannot be right.
> Can anybody reproduce this?

I can't.

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

* Re: c-mode eats resources?
  2006-02-18 21:07 c-mode eats resources? Paul Pogonyshev
  2006-02-18 22:40 ` Chong Yidong
@ 2006-02-18 22:47 ` Lennart Borgman
  2006-02-18 23:12 ` Luc Teirlinck
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Lennart Borgman @ 2006-02-18 22:47 UTC (permalink / raw)
  Cc: emacs-devel

Paul Pogonyshev wrote:
> Apparently, C mode constantly uses processor time even nothing is
> done in the buffer.  E.g. if I open a C file in Emacs and go to a
> different desktop and start `top' there, it shows Emacs in the
> first few lines with 3--7% usage of CPU.  This cannot be right.
> Can anybody reproduce this?
>
> Paul
>   
I just opened a C file with Emacs from CVS 2006-02-17 on w32 and I can 
not see this. (I e if I do not misunderstand this. I opened the C file 
and did M-x c-mode.)

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

* Re: c-mode eats resources?
  2006-02-18 21:07 c-mode eats resources? Paul Pogonyshev
  2006-02-18 22:40 ` Chong Yidong
  2006-02-18 22:47 ` Lennart Borgman
@ 2006-02-18 23:12 ` Luc Teirlinck
  2006-02-19 17:18   ` Juri Linkov
  2006-02-18 23:17 ` Luc Teirlinck
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Luc Teirlinck @ 2006-02-18 23:12 UTC (permalink / raw)
  Cc: emacs-devel

Paul Pogonyshev wrote:

   Apparently, C mode constantly uses processor time even nothing is
   done in the buffer.  E.g. if I open a C file in Emacs and go to a
   different desktop and start `top' there, it shows Emacs in the
   first few lines with 3--7% usage of CPU.  This cannot be right.
   Can anybody reproduce this?

Not really.  After visiting a large file in C mode, I see some CPU
time being used, probably to fontify the buffer, but it eventually
stops after using only a very few seconds total time (four for alloc.c
and maybe those four seconds were not even all used for C mode).

Did you customize font-lock related stuff to use potentially
inefficient regexps?

You could do `C-h v' on both timer-list and timer-idle-list to see
what you have running.

Sincerely,

Luc.

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

* Re: c-mode eats resources?
  2006-02-18 22:40 ` Chong Yidong
@ 2006-02-18 23:12   ` Paul Pogonyshev
  2006-02-19 11:12     ` martin rudalics
  0 siblings, 1 reply; 17+ messages in thread
From: Paul Pogonyshev @ 2006-02-18 23:12 UTC (permalink / raw)


OK, is there any way to find what Emacs runs in timeouts or something?
So that I can find what's going on if this repeats.

Paul

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

* Re: c-mode eats resources?
  2006-02-18 21:07 c-mode eats resources? Paul Pogonyshev
                   ` (2 preceding siblings ...)
  2006-02-18 23:12 ` Luc Teirlinck
@ 2006-02-18 23:17 ` Luc Teirlinck
  2006-02-19  0:02 ` Luc Teirlinck
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Luc Teirlinck @ 2006-02-18 23:17 UTC (permalink / raw)
  Cc: emacs-devel

Paul Pogonyshev wrote:

   Apparently, C mode constantly uses processor time even nothing is
   done in the buffer.  E.g. if I open a C file in Emacs and go to a
   different desktop and start `top' there, it shows Emacs in the
   first few lines with 3--7% usage of CPU.  This cannot be right.
   Can anybody reproduce this?

Can _you_ reproduce it using `emacs -q'?

Sincerely,

Luc.

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

* Re: c-mode eats resources?
  2006-02-18 21:07 c-mode eats resources? Paul Pogonyshev
                   ` (3 preceding siblings ...)
  2006-02-18 23:17 ` Luc Teirlinck
@ 2006-02-19  0:02 ` Luc Teirlinck
  2006-02-19 11:54   ` Paul Pogonyshev
  2006-02-19  0:05 ` Luc Teirlinck
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Luc Teirlinck @ 2006-02-19  0:02 UTC (permalink / raw)
  Cc: emacs-devel

>From my previous reply:

   Not really.  After visiting a large file in C mode, I see some CPU
   time being used, probably to fontify the buffer, but it eventually
   stops after using only a very few seconds total time (four for alloc.c
   and maybe those four seconds were not even all used for C mode).

Well, that is four seconds total _CPU_ time, for visiting alloc.c
using `emacs -q' on a 1.7GHZ dual Xeon.  Emacs does not run _all_ of
the time, although a lot, takes a maximum of 3.something CPU and
finishes in about 3 minutes _clock_ time.  If your machine would be a
lot slower than mine and/or if your file is a lot larger than alloc.c,
it could last for much longer than 3 minutes (although your maximum
CPU usage is about the double of mine, which should halve the clock
time).

So the questions are:

Do you see this in `emacs -q'?
Do you see it regardless of file size?

Sincerely,

Luc.

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

* Re: c-mode eats resources?
  2006-02-18 21:07 c-mode eats resources? Paul Pogonyshev
                   ` (4 preceding siblings ...)
  2006-02-19  0:02 ` Luc Teirlinck
@ 2006-02-19  0:05 ` Luc Teirlinck
  2006-02-19  1:00 ` Luc Teirlinck
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Luc Teirlinck @ 2006-02-19  0:05 UTC (permalink / raw)
  Cc: emacs-devel

>From my previous reply:

   takes a maximum of 3.something CPU

Obviously, I meant 3.something % of CPU.

Sincerely,

Luc.

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

* Re: c-mode eats resources?
  2006-02-18 21:07 c-mode eats resources? Paul Pogonyshev
                   ` (5 preceding siblings ...)
  2006-02-19  0:05 ` Luc Teirlinck
@ 2006-02-19  1:00 ` Luc Teirlinck
  2006-02-19 15:17 ` Stefan Monnier
  2006-02-19 22:47 ` Richard M. Stallman
  8 siblings, 0 replies; 17+ messages in thread
From: Luc Teirlinck @ 2006-02-19  1:00 UTC (permalink / raw)
  Cc: emacs-devel

>From my previous reply:

   Emacs does not run _all_ of the time, although a lot,

Well, it starts running more or less continuously with a 1.5-3.5 % CPU
usage after about 20 seconds, stopping after an additional 2.5 - 3
minutes.  Given that my jit-lock-stealth-time is 16 and my top
refreshes every five seconds, the 20 second delay makes sense for jit-lock.

Sincerely,

Luc.

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

* Re: c-mode eats resources?
  2006-02-18 23:12   ` Paul Pogonyshev
@ 2006-02-19 11:12     ` martin rudalics
  0 siblings, 0 replies; 17+ messages in thread
From: martin rudalics @ 2006-02-19 11:12 UTC (permalink / raw)
  Cc: emacs-devel

 > OK, is there any way to find what Emacs runs in timeouts or something?
 > So that I can find what's going on if this repeats.

Try to experiment with the following (not necessarily with emacs -q):

1. Set `jit-lock-stealth-time' to nil.

2. Increase the value of `jit-lock-context-time'.

3. Toggle `font-lock-mode'.

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

* Re: c-mode eats resources?
  2006-02-19  0:02 ` Luc Teirlinck
@ 2006-02-19 11:54   ` Paul Pogonyshev
  0 siblings, 0 replies; 17+ messages in thread
From: Paul Pogonyshev @ 2006-02-19 11:54 UTC (permalink / raw)
  Cc: Luc Teirlinck

Luc Teirlinck wrote:
> >From my previous reply:
> 
>    Not really.  After visiting a large file in C mode, I see some CPU
>    time being used, probably to fontify the buffer, but it eventually
>    stops after using only a very few seconds total time (four for alloc.c
>    and maybe those four seconds were not even all used for C mode).
> 
> Well, that is four seconds total _CPU_ time, for visiting alloc.c
> using `emacs -q' on a 1.7GHZ dual Xeon.  Emacs does not run _all_ of
> the time, although a lot, takes a maximum of 3.something CPU and
> finishes in about 3 minutes _clock_ time.  If your machine would be a
> lot slower than mine and/or if your file is a lot larger than alloc.c,
> it could last for much longer than 3 minutes (although your maximum
> CPU usage is about the double of mine, which should halve the clock
> time).
> 
> So the questions are:
> 
> Do you see this in `emacs -q'?
> Do you see it regardless of file size?

OK, that's probably it.  I just didn't expect that it would run for so
long.  Just checked now, it shows the similar pattern and stops after
some minutes.  Sorry for the noise.

Paul

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

* Re: c-mode eats resources?
  2006-02-18 21:07 c-mode eats resources? Paul Pogonyshev
                   ` (6 preceding siblings ...)
  2006-02-19  1:00 ` Luc Teirlinck
@ 2006-02-19 15:17 ` Stefan Monnier
  2006-02-19 22:47 ` Richard M. Stallman
  8 siblings, 0 replies; 17+ messages in thread
From: Stefan Monnier @ 2006-02-19 15:17 UTC (permalink / raw)
  Cc: emacs-devel

> Apparently, C mode constantly uses processor time even nothing is
> done in the buffer.  E.g. if I open a C file in Emacs and go to a
> different desktop and start `top' there, it shows Emacs in the
> first few lines with 3--7% usage of CPU.  This cannot be right.
> Can anybody reproduce this?

(setq jit-lock-stealth-time nil)


        Stefan

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

* Re: c-mode eats resources?
  2006-02-18 23:12 ` Luc Teirlinck
@ 2006-02-19 17:18   ` Juri Linkov
  2006-02-19 23:31     ` Andreas Schwab
  2006-02-20  8:18     ` Kim F. Storm
  0 siblings, 2 replies; 17+ messages in thread
From: Juri Linkov @ 2006-02-19 17:18 UTC (permalink / raw)
  Cc: emacs-devel, pogonyshev

>    Apparently, C mode constantly uses processor time even nothing is
>    done in the buffer.  E.g. if I open a C file in Emacs and go to a
>    different desktop and start `top' there, it shows Emacs in the
>    first few lines with 3--7% usage of CPU.  This cannot be right.
>    Can anybody reproduce this?

This problem can be reproduced with the following code evaluated
on a buffer in C mode:

(let ((start (float-time)))
  (font-lock-mode 1)
  (jit-lock-fontify-now (point-min) (point-max))
  (- (float-time) start))

> Did you customize font-lock related stuff to use potentially
> inefficient regexps?

I don't know whether due to very inefficient regexps or not, but in
the last few months fontification in C mode deteriorated drastically.
Evaluating the code above on alloc.c using `emacs -q --no-site-file'
on 1GHZ in different Emacs versions produces the following results:

GNU Emacs 21.4 - 0.5 sec
CVS 2004-04    - 3.5 sec
CVS 2005-09    - 6.8 sec
CVS 2006-02    - 10.0 sec

Given a few percents of CPU utilization, no wonder that stealth
fontification lasts several minutes.

-- 
Juri Linkov
http://www.jurta.org/emacs/

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

* Re: c-mode eats resources?
  2006-02-18 21:07 c-mode eats resources? Paul Pogonyshev
                   ` (7 preceding siblings ...)
  2006-02-19 15:17 ` Stefan Monnier
@ 2006-02-19 22:47 ` Richard M. Stallman
  8 siblings, 0 replies; 17+ messages in thread
From: Richard M. Stallman @ 2006-02-19 22:47 UTC (permalink / raw)
  Cc: emacs-devel

    Apparently, C mode constantly uses processor time even nothing is
    done in the buffer.  E.g. if I open a C file in Emacs and go to a
    different desktop and start `top' there, it shows Emacs in the
    first few lines with 3--7% usage of CPU.  This cannot be right.

Is this stealth fontification?

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

* Re: c-mode eats resources?
  2006-02-19 17:18   ` Juri Linkov
@ 2006-02-19 23:31     ` Andreas Schwab
  2006-02-20  8:18     ` Kim F. Storm
  1 sibling, 0 replies; 17+ messages in thread
From: Andreas Schwab @ 2006-02-19 23:31 UTC (permalink / raw)
  Cc: pogonyshev, Luc Teirlinck, emacs-devel

Juri Linkov <juri@jurta.org> writes:

> I don't know whether due to very inefficient regexps or not, but in
> the last few months fontification in C mode deteriorated drastically.
> Evaluating the code above on alloc.c using `emacs -q --no-site-file'
> on 1GHZ in different Emacs versions produces the following results:
>
> GNU Emacs 21.4 - 0.5 sec
> CVS 2004-04    - 3.5 sec
> CVS 2005-09    - 6.8 sec
> CVS 2006-02    - 10.0 sec

I'm measuring less than 8 seconds on a 700Mhz G3, and less than 3 seconds
on a 1.8Ghz G5.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: c-mode eats resources?
  2006-02-19 17:18   ` Juri Linkov
  2006-02-19 23:31     ` Andreas Schwab
@ 2006-02-20  8:18     ` Kim F. Storm
  2006-02-20 19:33       ` Juri Linkov
  1 sibling, 1 reply; 17+ messages in thread
From: Kim F. Storm @ 2006-02-20  8:18 UTC (permalink / raw)
  Cc: pogonyshev, Luc Teirlinck, emacs-devel

Juri Linkov <juri@jurta.org> writes:

>>    Apparently, C mode constantly uses processor time even nothing is
>>    done in the buffer.  E.g. if I open a C file in Emacs and go to a
>>    different desktop and start `top' there, it shows Emacs in the
>>    first few lines with 3--7% usage of CPU.  This cannot be right.
>>    Can anybody reproduce this?
>
> This problem can be reproduced with the following code evaluated
> on a buffer in C mode:
>
> (let ((start (float-time)))
>   (font-lock-mode 1)
>   (jit-lock-fontify-now (point-min) (point-max))
>   (- (float-time) start))
>
>> Did you customize font-lock related stuff to use potentially
>> inefficient regexps?
>
> I don't know whether due to very inefficient regexps or not, but in
> the last few months fontification in C mode deteriorated drastically.
> Evaluating the code above on alloc.c using `emacs -q --no-site-file'
> on 1GHZ in different Emacs versions produces the following results:
>
> GNU Emacs 21.4 - 0.5 sec
> CVS 2004-04    - 3.5 sec
> CVS 2005-09    - 6.8 sec
> CVS 2006-02    - 10.0 sec
>
> Given a few percents of CPU utilization, no wonder that stealth
> fontification lasts several minutes.

Does it help to increase the size of the regexp cache in search.c?

#define REGEXP_CACHE_SIZE 20

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: c-mode eats resources?
  2006-02-20  8:18     ` Kim F. Storm
@ 2006-02-20 19:33       ` Juri Linkov
  0 siblings, 0 replies; 17+ messages in thread
From: Juri Linkov @ 2006-02-20 19:33 UTC (permalink / raw)
  Cc: pogonyshev, teirllm, emacs-devel

>> (let ((start (float-time)))
>>   (font-lock-mode 1)
>>   (jit-lock-fontify-now (point-min) (point-max))
>>   (- (float-time) start))
>>
>> GNU Emacs 21.4 - 0.5 sec
>> CVS 2004-04    - 3.5 sec
>> CVS 2005-09    - 6.8 sec
>> CVS 2006-02    - 10.0 sec
>>
>> Given a few percents of CPU utilization, no wonder that stealth
>> fontification lasts several minutes.
>
> Does it help to increase the size of the regexp cache in search.c?
>
> #define REGEXP_CACHE_SIZE 20

I increased it to 2020 (this also required increasing NSTATICS twice to 5280),
and on the first test (on the current CVS) the result was 7.0 sec.

However, on subsequent evaluations the result started degrading:

1 - 7.0
2 - 7.0
3 - 8.4
4 - 9.5
5 - 9.5

After that, I reopened alloc.c, and again, on the first
evaluation the result was 7.1 sec, but on subsequent tests
the fontification time increased:

1 - 7.1
2 - 7.6
3 - 7.9
4 - 8.4
5 - 9.4

-- 
Juri Linkov
http://www.jurta.org/emacs/

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

end of thread, other threads:[~2006-02-20 19:33 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-18 21:07 c-mode eats resources? Paul Pogonyshev
2006-02-18 22:40 ` Chong Yidong
2006-02-18 23:12   ` Paul Pogonyshev
2006-02-19 11:12     ` martin rudalics
2006-02-18 22:47 ` Lennart Borgman
2006-02-18 23:12 ` Luc Teirlinck
2006-02-19 17:18   ` Juri Linkov
2006-02-19 23:31     ` Andreas Schwab
2006-02-20  8:18     ` Kim F. Storm
2006-02-20 19:33       ` Juri Linkov
2006-02-18 23:17 ` Luc Teirlinck
2006-02-19  0:02 ` Luc Teirlinck
2006-02-19 11:54   ` Paul Pogonyshev
2006-02-19  0:05 ` Luc Teirlinck
2006-02-19  1:00 ` Luc Teirlinck
2006-02-19 15:17 ` Stefan Monnier
2006-02-19 22:47 ` Richard M. Stallman

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.