www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/11/29/12:30:32

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
Date: Mon, 29 Nov 2010 18:29:57 +0100
From: David Sastre <d DOT sastre DOT medina AT gmail DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: /etc/profile optimization and correctness
Message-ID: <20101129172956.GA5039@jethro.local.lan>
References: <4CF3A930 DOT 40404 AT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <4CF3A930.40404@gmail.com>
User-Agent: Mutt/1.5.20 (2009-06-14)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--uAKRQypu60I7Lcqm
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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:
>=20
> - Can't we use USERNAME to set USER instead of running `id -un`?
>=20
> - 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
>=20
> - Detect the current shell by examining BASH_VERSION, ZSH_VERSION, and
> so on, not by forking for the echo|tr|sed pipeline.
>=20
> - Use this code to run the profile.d scripts:
> saved_LC_COLLATE=3D$LC_COLLATE
> LC_COLLATE=3DC
> for file in /etc/profile.d/*.{sh,zsh}; do
>   LC_COLLATE=3D$saved_LC_COLLATE
>   test -a "$file" && . "$file"
> done
> unset saved_LC_COLLATE
>=20
> - 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.
>=20
> - 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.)
>=20
> - Replace the invocation of regtool with a direct read from
> /proc/registry. That is, instead of
>=20
> # Three forks
> PRINTER=3D"`regtool -q get '\user\Software\Microsoft\Windows
> NT\CurrentVersion\Windows\Device' | sed 's/,.*$//'`"
>=20
> use
>=20
> # Zero forks
> read -r PRINTER <
> '/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows
> NT/CurrentVersion/Windows/Device'
> export PRINTER=3D${PRINTER%%,*}
>=20
>=20
>=20
> I've modified my own /etc/profile. It ends up being an order of
> magnitude faster than the stock version:
>=20
> dancol AT xyzzy ~
> $ time . /etc/defaults/etc/profile
>=20
> real	0m1.012s
> user	0m0.075s
> sys	0m0.318s
>=20
> dancol AT xyzzy ~
> $ time . /etc/profile
>=20
> 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=20
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) :)

--=20
Huella de clave primaria: 0FDA C36F F110 54F4 D42B  D0EB 617D 396C 448B 31EB

--uAKRQypu60I7Lcqm
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkzz4xQACgkQYX05bESLMesHJQCeM2BsGFdiPU1cQrLFbsDHPiuW
RNYAniQb8/tNXt9skVXDW/C9JyijjezV
=7rVP
-----END PGP SIGNATURE-----

--uAKRQypu60I7Lcqm--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019