| Summary: | systat(1) waste too much time reading input | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Vladimir B.Grebenschikov <vova> |
| Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed DUPLICATE | ||
| Severity: | Affects Only Me | CC: | jilles |
| Priority: | Normal | ||
| Version: | 5.0-CURRENT | ||
| Hardware: | Any | ||
| OS: | Any | ||
|
Description
Vladimir B.Grebenschikov
2001-12-10 11:40:00 UTC
State Changed From-To: open->feedback I'm hoping the originator will take a crack at this himself, now that he knows where the problem is. :-) On Mon, 10 Dec 2001 14:32:24 +0300, "Vladimir B.Grebenschikov" wrote:
> >Number: 32667
> >Category: bin
> >Synopsis: systat waste too much time reading input
The problem is a very tight loop around getch() in non-delay mode, in
the keyboard() function in keyboard.c. This should probably be changed
to half-delay mode.
Someone who knows ncurses(3X) (or who is willing to learn) will have to
look at this.
Well-spotted. Interested in trying to come up with a patch, based on a
squizz at the getch(3) and ncurses(3X) manual pages?
Cioa,
Sheldon.
On Mon, 10 Dec 2001, Vladimir B.Grebenschikov wrote: > Have tried also on 4.4-RELEASE - same problem > >Description: > I have found that on same, not busy system top & systat runing > simulataniosly "eat" very different amount of CPU time, like: > > CPU > 5.37% systat > 0.01% top > > triing find out what happens, I have tried to run > systat -vm 1 < /dev/null > And found that systat eats a lot of system resources during input > > WCPU CPU > 63.05% 16.36% systat This seems to be because the VM_METER sysctl is increadibly slow. It takes 13 msec here on an Athlon1600XP system with 512MB memory, but "only" 3 msec on a Celeron366 system with 256MB memory. Bruce On Mon, 10 Dec 2001 05:30:02 PST, Bruce Evans wrote:
> This seems to be because the VM_METER sysctl is increadibly slow. It
> takes 13 msec here on an Athlon1600XP system with 512MB memory, but
> "only" 3 msec on a Celeron366 system with 256MB memory.
Are you sure?
The originator reports that the following patch (which he sent me in
private) makes the symptoms go away. Is it just because it reduces the
number of queries to no more than 1 per second?
Ciao,
Sheldon.
Index: keyboard.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/systat/keyboard.c,v
retrieving revision 1.1.1.1
diff -u -d -r1.1.1.1 keyboard.c
--- keyboard.c 27 May 1994 12:32:44 -0000 1.1.1.1
+++ keyboard.c 10 Dec 2001 13:37:07 -0000
@@ -54,8 +54,10 @@
do {
refresh();
ch = getch() & 0177;
- if (ch == 0177 && ferror(stdin)) {
- clearerr(stdin);
+ if (ch == 0177) {
+ sleep(1);
+ if (ferror(stdin))
+ clearerr(stdin);
continue;
}
if (ch >= 'A' && ch <= 'Z')
Index: main.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/systat/main.c,v
retrieving revision 1.15
diff -u -d -r1.15 main.c
--- main.c 25 May 2001 23:10:27 -0000 1.15
+++ main.c 10 Dec 2001 13:25:56 -0000
@@ -174,7 +174,7 @@
signal(SIGALRM, display);
display(0);
noecho();
- crmode();
+ halfdelay(10);
keyboard();
/*NOTREACHED*/
On Mon, 10 Dec 2001, Sheldon Hearn wrote: > On Mon, 10 Dec 2001 05:30:02 PST, Bruce Evans wrote: > > > This seems to be because the VM_METER sysctl is increadibly slow. It > > takes 13 msec here on an Athlon1600XP system with 512MB memory, but > > "only" 3 msec on a Celeron366 system with 256MB memory. > > Are you sure? > > The originator reports that the following patch (which he sent me in > private) makes the symptoms go away. Is it just because it reduces the > number of queries to no more than 1 per second? I didn't notice the redirection of stdin in the PR and found a completely different problem: "systat -v 1" shows itself taking 1.5% overhead on one system. This is mostly from one syscall that takes 13+ msec being called every second. I guess it could take even longer on a machine with more mmory and/or more processes. Bruce State Changed From-To: feedback->open We've had feedback from both bde and the originator. One problem is easy to fix, the other harder. :-) For PR bin/107171, SVN r197956 changed systat to exit if getch() returns an error other than [EINTR]. This fixes the infinite loop problem. The VM_METER sysctl is inherently slow because what it does: it iterates over all processes, threads and VM objects. The sysctl(8) output suggests that the totals are computed every five seconds, but in fact this happens when the sysctl is read. *** This bug has been marked as a duplicate of bug 107171 *** MARKED AS SPAM |