From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 2113 invoked from network); 20 May 2022 10:35:10 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 20 May 2022 10:35:10 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1653042910; b=lxeq6aOBT3bt9DcGFosjJXooqRUXcpgfVTd8bmwpCqR6cmpS4W9f8m9MxbUVRhMO3qyUFuypG7 IE2Y0hsQ8E2NLZbkLtbXxLRurhlxtrPnw19QfJkx6xGRvncc3XGyxBWspsnfRXi7pbh5bTD9YK z+h7DCngypELHHTGAYb3yBYyyPiLfgqzMYbJwNkpqcFTdesykhgqKJ2GbJ7zH0cK5Wm9YxvCiG 3MGfGnh8JFn5yargyYQtS9MrFvWGWbCyERJzH+piq0JfsIN46LaHNmPIPDFy2oOMqxtUIiufm7 PRWeCTM7GR8wmg+c83f2jg6BS4r4W/tB7H1Jv8sFSYyylA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-pj1-f43.google.com) smtp.remote-ip=209.85.216.43; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1653042910; bh=Tim3Pfjo/CQ2u8mgoOdMkUr3c6jWH9OoAdg+oX8Glis=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:References: In-Reply-To:MIME-Version:DKIM-Signature:DKIM-Signature; b=Mk6WLuJASF7AmKhRjxjpqbnZNitMPUk2x88zc2U/lVDHwisvEIX2AK5YUjfKJJ4AoSag777/5L 2/7tvx2ErJkckevmycx+5QkZ6jkVPALlhhB+64dr6E7d6tV6sdNMFKW/NVlZkL1yiLXzlSMR45 FW/V9ToSxKHTtbv+0JXk1yMPuj/5lRSuwr2LQYu2qt3gMlfX0YDkhWtqfd1CsRjDsowDQCPbBZ SDLbN57cRnp/3PtI3K6dJv5JIEjXVFvTSkxZbGvfRpMT/QJCrNaQFFdlwswIEq5F/ogedIe5BG LX3LmYZvUxV9mPibrFsH+0ePy0XCWc1llZ8MHLpu5lsL+Q==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:References:In-Reply-To:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=lDHJT9UtndYjUaQ6Hj286ttklYlc/kIFSzT8I3zUfHI=; b=EtBtKFwklvsEi5Jo8SCoGQ32ks eRkKEPN/rFbY/h72Qq3/7WqGJ/gH7xmezO/1gfHPrOlgE5mjkDE2fgK5pIbw2CFY+HlQj9NmzJi1t pb7AkEw9na8KPwLRIB6TWCRv9Tbdlr49LKQm3MP1gdVB3LGq6/dg4kEu0dBPg2wpPKumXmtIoJmWi K8Ec9IGyufgWTVQ1nRtU6X7FuYNCVxDe76biiUj4Mnw4EnRIxj2rbf4k/NsfU6xW8Igf9RAahxael Hd71fBUBQ7PJQ3laVWsOtDqlC/sHLHWXCMUiHcS4zCI4snYGjxU1oJAOyhHiqJzvGXWFJNkrOx8bg sUZjkHfg==; Received: from authenticated user by zero.zsh.org with local id 1nrzyP-000K8L-KQ; Fri, 20 May 2022 10:35:09 +0000 Authentication-Results: zsh.org; iprev=pass (mail-pj1-f43.google.com) smtp.remote-ip=209.85.216.43; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-pj1-f43.google.com ([209.85.216.43]:38798) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1nrzyA-000JoI-GX; Fri, 20 May 2022 10:34:55 +0000 Received: by mail-pj1-f43.google.com with SMTP id o13-20020a17090a9f8d00b001df3fc52ea7so11135259pjp.3 for ; Fri, 20 May 2022 03:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=lDHJT9UtndYjUaQ6Hj286ttklYlc/kIFSzT8I3zUfHI=; b=GBEiZeZ9hlVoohC0qugWdFTNHhxJhyi7b9hiypB3XZX7qW+J34BeN4gvu2hKcfdFmO rZxVAHxL5CntimN02mQARkIOS9+SsYnVVfMKKMCFoFNHOkH0PoTTitWGLUkeuExNEMHE kfBcvLRQPbT6jSDKPo6j+AhcFamI3UQMEfUE1vaMPC8CwuLMxsou+HSDh8nf1B2HYalm yFoBdWIVtKtbnHm3Vbi/Wi1GUwDWVgYY2/NfEwaO/zq4+XsYTwHRHWY9X1ZttWzab4md ovAyOwD612MiNcSCV09fC1zegInSTqhL5e3/dMh1UhIgBnLzle89vpq5lm0trIP/CxYW ViKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=lDHJT9UtndYjUaQ6Hj286ttklYlc/kIFSzT8I3zUfHI=; b=LtsNLwWgTxdeLfPjJ4RjfwcmjGg//sNkZJqznDdaK+KuMAXRn2OQ7dslx1O8bwbKK4 /lM3lUP0Sqs2i2+xh6qdTzPjnTPHEjNCQok11/pK9YtGPdIJXqjE0TF6BnpacUxYQaDI poZ0j/zmp181/5BpELycn5I9RGmgHwb4JDqZVsSTf/vtvpwnBbh+9CV5JneZs47QZaOm 5rD+JEY+NjM/6V/EgF0mZOWovTTTQRrr2yz0590ehWVwKPLj5GLIAhZ/nFOeD0uomfH+ p5MnF6LW7CTP17BJWxaAzUi2tQTnfpcHIQD6jUlrMWkN1awxxuetSKMUZr6ZJshq5qTb W+pA== X-Gm-Message-State: AOAM5312sySCfK7FR1p58yMbbDPWhHwAPv9rGf/PptcLOxpIqw/+orW8 sTYC3hlFT2eAafj8wXaLbuabn+zVeQqB5uRbsMxIw+BK X-Google-Smtp-Source: ABdhPJzPNT2TAT7/+rcTqFY8071WvDCpx/f5nY4h9eS4ZtrNATJMheB3HRxHtleu7avS0EPox+0NUZ0GXortsnxQPak= X-Received: by 2002:a17:903:110e:b0:15e:f450:bee8 with SMTP id n14-20020a170903110e00b0015ef450bee8mr9049733plh.136.1653042893199; Fri, 20 May 2022 03:34:53 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:6a10:e897:0:0:0:0 with HTTP; Fri, 20 May 2022 03:34:52 -0700 (PDT) In-Reply-To: References: From: Mikael Magnusson Date: Fri, 20 May 2022 12:34:52 +0200 Message-ID: Subject: Re: Using the history expansion modifier 'a' results in excessive lstat calls To: Stefan Radziuk Cc: "zsh-workers@zsh.org" Content-Type: text/plain; charset="UTF-8" X-Seq: 50261 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On 5/20/22, Stefan Radziuk wrote: > 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). Do you get the same results with :P ? :a and :A are not guaranteed to result in a path leading to the same file (eg, symlink/../ will be simply deleted without following the symlink etc) -- Mikael Magnusson