[comp.emacs] GNUEmacs using all the CPU on my Sun4

felix@ai.sri.com (Francois Felix INGRAND) (08/14/90)

I have notice that GNUEmacs is using "lot of CPU" on my Sparc 1+.

Here is a top 10, and as you can see, although I am doing nothing, the 2
gnuemacs are using 22% each. (The X server is getting a good share too).

All these process are "idle". Does that mean that emacs is continuously
checking for inputs and therefore, forcing the system in heavy context
switching activities?

Is is possible to avoid this problem?

last pid:  1550;  load averages:  1.40,  1.36,  1.02                   16:44:55
51 processes:  49 sleeping, 2 running
Cpu states: 18.4% user,  0.0% nice, 81.6% system,  0.0% idle
Memory: 35920K (14608K) real, 16648K free

  PID USERNAME PRI NICE   SIZE   RES STATE   TIME   WCPU    CPU COMMAND
 1481 felix     49    0  2536K 2648K run     2:27 29.34% 29.30% Xsun
 1503 felix      1    0  4448K 3296K sleep   2:01 22.30% 22.27% gnuemacs
 1493 felix      1    0  3352K 2176K sleep   1:45 21.12% 21.09% gnuemacs
 1531 felix     25    0   352K  752K run     0:06  0.00%  0.00% top
 1463 felix     15    0   568K  840K sleep   0:00  0.00%  0.00% tcsh
 1526 felix     15    0   544K  816K sleep   0:00  0.00%  0.00% tcsh
 1511 felix     15    0   104K  344K sleep   0:00  0.00%  0.00% loadst
 1510 felix     15    0   104K  344K sleep   0:00  0.00%  0.00% loadst
  152 root      15    0    24K   16K sleep   0:35  0.00%  0.00% update
 1480 felix      5    0    88K  584K sleep   0:00  0.00%  0.00% xinit

As shown on the vmstat, cs is quite high...

cayucos% felix [22]:vmstat 1
 procs     memory              page               disk       faults     cpu
 r b w   avm   fre  re at  pi  po  fr  de  sr d0 d1 d2 s3  in  sy  cs us sy id
 1 0 0     0  8492   0189   7   4   7   0   1  1  0  0  0  591690 296 11 29 60
 1 0 0     0  8492   0  6   0   0   0   0   0  0  0  0  0  765157 869 17 83  0
 2 0 0     0  8480   0  4   0   0   0   0   0  0  0  0  0  855230 879 18 82  0
 2 0 0     0  8480   0  3   0   0   0   0   0  0  0  0  0 1145212 877 17 83  0
 2 0 0     0  8480   0  2   0   0   0   0   0  0  0  0  0 1395215 878 22 78  0
 2 0 0     0  8480   0  1   0   0   0   0   0  0  0  0  0 1435264 885 22 78  0
 2 0 0     0  8480   0  0   0   0   0   0   0  0  0  0  0 1225354 899 22 78  0
 2 0 0     0  8436   0  0   0   0   0   0   0  0  0  0  0 1005442 913 23 77  0
 2 0 0     0  8436   0  2   0   0   0   0   0  3  0  0  0  865453 916 16 84  0
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Francois Felix INGRAND                          SRI International, AIC
felix@AI.SRI.COM                                333, Ravenswood Avenue
(415) 859-5584                                  MENLO PARK, CA 94025, USA
"Read my Lisp... No new syntax" (nil)

meissner@osf.org (Michael Meissner) (08/14/90)

In article <FELIX.90Aug13165019@cayucos.ai.sri.com> felix@ai.sri.com
(Francois Felix INGRAND) writes:

| I have notice that GNUEmacs is using "lot of CPU" on my Sparc 1+.
| 
| Here is a top 10, and as you can see, although I am doing nothing, the 2
| gnuemacs are using 22% each. (The X server is getting a good share too).
| 
| All these process are "idle". Does that mean that emacs is continuously
| checking for inputs and therefore, forcing the system in heavy context
| switching activities?
| 
| Is is possible to avoid this problem?

I don't know if it helps, but I used to see this on a Sun3 if the X
server died, or emacs was left running after a session ended.  By
making sure emacs was done before shutting down a session I avoided
the problem.
--
Michael Meissner	email: meissner@osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

Do apple growers tell their kids money doesn't grow on bushes?

felix@ai.sri.com (Francois Felix INGRAND) (08/15/90)

In article <FELIX.90Aug13165019@cayucos.ai.sri.com> felix@ai.sri.com (Francois Felix INGRAND) writes:
>
>From: felix@ai.sri.com (Francois Felix INGRAND)
>Newsgroups: comp.emacs,gnu.emacs
>Date: 13 Aug 90 23:50:19 GMT
>
>I have notice that GNUEmacs is using "lot of CPU" on my Sparc 1+.
>
>Here is a top 10, and as you can see, although I am doing nothing, the 2
>gnuemacs are using 22% each. (The X server is getting a good share too).
>
>All these process are "idle". Does that mean that emacs is continuously
>checking for inputs and therefore, forcing the system in heavy context
>switching activities?

It looks like this problem only occurs when you run gnuemacs under X and most
likely on Sparcstation . I cannot reproduce it under SUNVIEW.

tmb@ai.mit.edu (Thomas M. Breuel) wrote:
"
GNU Emacs will sometimes get into a mode where it keeps talking
to the X server. This is really harmless and doesn't seem to slow
down the machine significantly.
"

My feeling is that nevertheless, it is eating some CPU on my sparc. All these
context switch reported by vmstat are not "free", and are probably responsible
for the high system time (80%). So I am not so sure that this is harmless.

I would appreciate some comments from GNUEmacs/X/Sparc gurus on this matter.

last pid:  1550;  load averages:  1.40,  1.36,  1.02                   16:44:55
51 processes:  49 sleeping, 2 running
Cpu states: 18.4% user,  0.0% nice, 81.6% system,  0.0% idle
Memory: 35920K (14608K) real, 16648K free

  PID USERNAME PRI NICE   SIZE   RES STATE   TIME   WCPU    CPU COMMAND
 1481 felix     49    0  2536K 2648K run     2:27 29.34% 29.30% Xsun
 1503 felix      1    0  4448K 3296K sleep   2:01 22.30% 22.27% gnuemacs
 1493 felix      1    0  3352K 2176K sleep   1:45 21.12% 21.09% gnuemacs
 1531 felix     25    0   352K  752K run     0:06  0.00%  0.00% top
 1463 felix     15    0   568K  840K sleep   0:00  0.00%  0.00% tcsh
 1526 felix     15    0   544K  816K sleep   0:00  0.00%  0.00% tcsh
 1511 felix     15    0   104K  344K sleep   0:00  0.00%  0.00% loadst
 1510 felix     15    0   104K  344K sleep   0:00  0.00%  0.00% loadst
  152 root      15    0    24K   16K sleep   0:35  0.00%  0.00% update
 1480 felix      5    0    88K  584K sleep   0:00  0.00%  0.00% xinit

As shown on the vmstat, cs is quite high...

cayucos% felix [22]:vmstat 1
 procs     memory              page               disk       faults     cpu
 r b w   avm   fre  re at  pi  po  fr  de  sr d0 d1 d2 s3  in  sy  cs us sy id
 1 0 0     0  8492   0189   7   4   7   0   1  1  0  0  0  591690 296 11 29 60
 1 0 0     0  8492   0  6   0   0   0   0   0  0  0  0  0  765157 869 17 83  0
 2 0 0     0  8480   0  4   0   0   0   0   0  0  0  0  0  855230 879 18 82  0
 2 0 0     0  8480   0  3   0   0   0   0   0  0  0  0  0 1145212 877 17 83  0
 2 0 0     0  8480   0  2   0   0   0   0   0  0  0  0  0 1395215 878 22 78  0
 2 0 0     0  8480   0  1   0   0   0   0   0  0  0  0  0 1435264 885 22 78  0
 2 0 0     0  8480   0  0   0   0   0   0   0  0  0  0  0 1225354 899 22 78  0
 2 0 0     0  8436   0  0   0   0   0   0   0  0  0  0  0 1005442 913 23 77  0
 2 0 0     0  8436   0  2   0   0   0   0   0  3  0  0  0  865453 916 16 84  0
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Francois Felix INGRAND                          SRI International, AIC
felix@AI.SRI.COM                                333, Ravenswood Avenue
(415) 859-5584                                  MENLO PARK, CA 94025, USA
"Read my Lisp... No new syntax" (nil)

cs@Eng.Sun.COM (Carl Smith) (08/15/90)

In article <FELIX.90Aug13165019@cayucos.ai.sri.com>, felix@ai.sri.com
(Francois Felix INGRAND) writes:
> 
> I have notice that GNUEmacs is using "lot of CPU" on my Sparc 1+.
...
> Is is possible to avoid this problem?

	I stumbled onto a workaround trying to investigate this.  Simply trace
each of the offending processes (e.g. ``trace -p 1503'') for a bit. 
You'll
notice rather a lot of output at first, then it will become quiescent.

			Carl

duty@ariel.its.unimelb.edu.au (Duty Programmer) (08/15/90)

In article <FELIX.90Aug13165019@cayucos.ai.sri.com> felix@ai.sri.com (Francois Felix INGRAND) writes:
>
>I have notice that GNUEmacs is using "lot of CPU" on my Sparc 1+.

I have noticed the same thing running MicroEmacs under AOS/VS ! Now, I don't
have the source code handy, but does Emacs do function calls for every
keystroke? If it does, then this could slow things up a bit...?

rab
--
Richard Brown                     | E-mail: rab@ariel.its.unimelb.EDU.AU
School of Physics                 | Phone : +61 3 344 5081
University of Melbourne           | Fax   : +61 3 347 4783
Parkville Victoria AUSTRALIA 3052 | Telex : AA35185

shore@mtxinu.COM (Melinda Shore) (08/16/90)

In article <204@ariel.its.unimelb.edu.au> duty@ariel.its.unimelb.edu.au (Duty Programmer) writes:
>Now, I don't
>have the source code handy, but does Emacs do function calls for every
>keystroke? 

Function calls?  Heck, I did some tracing under Mach and found
that emacs did 20-30 *system calls* per keystroke under X.  

>If it does, then this could slow things up a bit...?

A tad.
-- 
Melinda Shore                             shore@mtxinu.com
mt Xinu                          ..!uunet!mtxinu.com!shore