delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-1.0 required=5.0 tests=AWL,BAYES_40,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL |
X-Spam-Check-By: | sourceware.org |
Message-ID: | <4CF3A930.40404@gmail.com> |
Date: | Mon, 29 Nov 2010 05:22:56 -0800 |
From: | Daniel Colascione <dan DOT colascione AT gmail DOT com> |
User-Agent: | Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6 |
MIME-Version: | 1.0 |
To: | cygwin AT cygwin DOT com |
Subject: | /etc/profile optimization and correctness |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.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 |
--------------enig3831C2B1D25AE248EEDE6F55 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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=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 - 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=3D"`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=3D${PRINTER%%,*} I've modified my own /etc/profile. It ends up being an order of magnitude faster than the stock version: dancol AT xyzzy ~ $ time . /etc/defaults/etc/profile real 0m1.012s user 0m0.075s sys 0m0.318s dancol AT xyzzy ~ $ time . /etc/profile real 0m0.104s user 0m0.015s sys 0m0.015s --------------enig3831C2B1D25AE248EEDE6F55 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iEYEARECAAYFAkzzqTIACgkQ17c2LVA10VvxWACdEmZSVWqKd1bUqV/gcfxMr/81 F6EAn2uUiGebTypWDE2WpjrxzuA1My/J =E0gG -----END PGP SIGNATURE----- --------------enig3831C2B1D25AE248EEDE6F55--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |