Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Good grief! Thousands of calls to stat()



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



Messages sorted by: Reverse Date, Date, Thread, Author