help / color / mirror / code / Atom feed
From: Stefan Radziuk <sradziuk@pdtpartners.com>
To: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Using the history expansion modifier 'a' results in excessive lstat calls
Date: Fri, 20 May 2022 10:08:01 +0000	[thread overview]
Message-ID: <CY5PR20MB4843E231D8BA513A209C6541C1D39@CY5PR20MB4843.namprd20.prod.outlook.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2156 bytes --]

zsh uses zgetdir to evaluate ${FOO:a}. When in a directory in a different filesystem to its parent,  zgetdir will lstat many entries in the parent. This leads to slowness, especially when some of the lstatted entries are on remote filesystems.

This behaviour can be avoided by making zsh use getcwd instead (build zsh with USE_GETCWD). Interestingly, getcwd will also be used in the regular zsh build if zgetdir fails (see the implementation of zgetcwd).

I have looked through some threads in the mailing list to find out why zgetdir is being used over getcwd in the first place. It seems it was implemented this way in the 1990s to work around a bug in some implementations of getcwd, which should not be a concern on modern systems.

I was wondering if zgetdir is still the right way to do this? Are there use cases where it is preferred over getcwd? Maybe zgetcwd could simply use getcwd primarily (i.e. not as fallback), or perhaps USE_GETCWD could be enabled by default (currently it is only enabled on QNX builds).

This communication is intended only for the addressee(s), may contain confidential, privileged or proprietary information, and may be protected by US and other laws. Your acceptance of this communication constitutes your agreement to keep confidential all the confidential information contained in this communication, as well as any information derived by you from the confidential information contained in this communication. We do not waive any confidentiality by misdelivery.

If you receive this communication in error, any use, dissemination, printing or copying is strictly prohibited; please destroy all electronic and paper copies and notify the sender immediately. Nothing in this email is intended to constitute (1) investment or trading advice or recommendations or any advertisement or (2) a solicitation of an investment in any jurisdiction in which such a solicitation would be unlawful.

Please note that PDT Partners UK, LLP, including its affiliates, reserves the right to intercept, archive, monitor and review all communications to and from its network.

[-- Attachment #2: Type: text/html, Size: 5019 bytes --]

             reply	other threads:[~2022-05-20 10:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-20 10:08 Stefan Radziuk [this message]
2022-05-20 10:15 ` Peter Stephenson
2022-05-25  9:53   ` Peter Stephenson
2022-05-25 10:22     ` (EXT) " Stefan Radziuk
2022-05-25 10:33       ` Peter Stephenson
2022-05-26  8:35         ` Peter Stephenson
2022-05-20 10:34 ` Mikael Magnusson
2022-05-23 11:32   ` (EXT) " Stefan Radziuk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CY5PR20MB4843E231D8BA513A209C6541C1D39@CY5PR20MB4843.namprd20.prod.outlook.com \
    --to=sradziuk@pdtpartners.com \
    --cc=zsh-workers@zsh.org \
    --subject='Re: Using the history expansion modifier '\''a'\'' results in excessive lstat calls' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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


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).