zsh-workers
 help / color / mirror / code / Atom feed
* Good grief!  Thousands of calls to stat()
@ 1999-01-30 21:40 Bart Schaefer
  1999-01-30 23:18 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 1999-01-30 21:40 UTC (permalink / raw)
  To: zsh-workers

In the course of looking at Drazen's tty-initialization bugs/questions, I
happened to try running

strace -f zsh -i 2>& 1 > /dev/null < /dev/null

(for version 3.1.6-pws-6).  Imagine my surprise when hundreds of screenfuls
of calls to stat() went by -- in fact, there appears to be a loop that calls
stat() once for each file in /dev, and that loop runs three times.

After much peering at the surrounding output, I finally stuck some calls to
write() into setupvals() and tracked it as far as createparamtable() -- the
first system call after entering createparamtable() is the brk() to allocate
the space, and it finally surfaces 4130 system calls later, nearly all of
which are stat("/dev/somethingorother").

Anybody have any idea what's going on here?  I'll try to narrow it further,
but with all the functions that get run callback-style when certain of the
parameters are changed, it's a real pain.

There's even a call to ioctl(0, TIOCGWINSZ, ...) happening among those 4130
system calls, which is really strange because by that time SHTTY is already
fd 10 and only ioctl(SHTTY, TIOCGWINSZ, ...) appears in the zsh source.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: Good grief!  Thousands of calls to stat()
  1999-01-30 21:40 Good grief! Thousands of calls to stat() Bart Schaefer
@ 1999-01-30 23:18 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 1999-01-30 23:18 UTC (permalink / raw)
  To: zsh-workers

On Jan 30,  1:40pm, Bart Schaefer wrote:
} Subject: Good grief!  Thousands of calls to stat()
}
} first system call after entering createparamtable() is the brk() to allocate
} the space, and it finally surfaces 4130 system calls later, nearly all of
} which are stat("/dev/somethingorother").

I've traced this to the call to getlogin() when initializing the value of
the LOGNAME variable.  It appears to happen only when some or all of stdin,
stdout, and stderr are redirected away from the terminal (the more of them
that are redirected, the worse it gets).

Although this doesn't have much effect on interactive shells, it probably
causes the startup time of some zsh scripts to be significantly longer
than the same script running under some other shell.

Any suggestions what we could do about it?  How about, trust the username
obtained from getpwuid(), which is what happens in this case anyway after
getlogin() finally gives up?

} There's even a call to ioctl(0, TIOCGWINSZ, ...)

That one happens when TERM is imported from the environment, so it must
be something internal to tgetent() via init_term() via termsetfn().  This
is another thing that probably shouldn't happen when the shell is not an
interactive one.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

end of thread, other threads:[~1999-01-30 23:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-30 21:40 Good grief! Thousands of calls to stat() Bart Schaefer
1999-01-30 23:18 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).