On Mon, Nov 29, 2010 at 05:22:56AM -0800, Daniel Colascione wrote: > Starting a login shell on my system takes a painfully long time, mostly > because fork() is pretty slow on WOW6432 systems. I've taken a look at > the shell initialization routines and identified some potential savings: > > - Can't we use USERNAME to set USER instead of running `id -un`? > > - Move the /tmp chmod to the user-home-directory-doesn't-exist-case, or > better yet, get rid of it altogether and move /tmp permission setting to > install scripts > > - Detect the current shell by examining BASH_VERSION, ZSH_VERSION, and > so on, not by forking for the echo|tr|sed pipeline. > > - Use this code to run the profile.d scripts: > saved_LC_COLLATE=$LC_COLLATE > LC_COLLATE=C > for file in /etc/profile.d/*.{sh,zsh}; do > LC_COLLATE=$saved_LC_COLLATE > test -a "$file" && . "$file" > done > unset saved_LC_COLLATE > > - The default /etc/profile exports PS1. Please don't do that: it causes > weird issues with Emacs tramp; it causes other shells that interpret PS1 > differently (like zsh) to do odd things; and it uses up precious > environment-block space. Better to set PS1 in bashrc. > > - There's a useless uname -s invocation: since Cygwin doesn't run on > Windows 9x anymore (and good riddance!), the first branch of the > conditional is always taken. (Saves two forks.) > > - Replace the invocation of regtool with a direct read from > /proc/registry. That is, instead of > > # Three forks > PRINTER="`regtool -q get '\user\Software\Microsoft\Windows > NT\CurrentVersion\Windows\Device' | sed 's/,.*$//'`" > > use > > # Zero forks > read -r PRINTER < > '/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows > NT/CurrentVersion/Windows/Device' > export PRINTER=${PRINTER%%,*} > > > > I've modified my own /etc/profile. It ends up being an order of > magnitude faster than the stock version: > > dan...@xyzzy ~ > $ time . /etc/defaults/etc/profile > > real 0m1.012s > user 0m0.075s > sys 0m0.318s > > dan...@xyzzy ~ > $ time . /etc/profile > > real 0m0.104s > user 0m0.015s > sys 0m0.015s
I'm already working in some changes in base-files to include some bugfixes, and hopefully improve start-up performance by reorganizing how things are done now. I'll check your proposals. One thing: we need to set at least a minimum PS1 in /etc/profile, because every shell (except tcsh and zsh) fallback to that setting in case there are no ~/.${SHELL}rc and friends. And also because not everybody uses bash (even though it is the default one) :) -- Huella de clave primaria: 0FDA C36F F110 54F4 D42B D0EB 617D 396C 448B 31EB
signature.asc
Description: Digital signature