zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Extended globbing seems to have become much slower in recent versions of Zsh
Date: Sat, 5 Mar 2016 09:37:06 -0800	[thread overview]
Message-ID: <160305093706.ZM22241@torch.brasslantern.com> (raw)
In-Reply-To: <CABZhJg8jyO05TWd2Q2KALKb8ib+x_o_0iP0+SAE+W1h6so87xg@mail.gmail.com>

On Mar 4,  2:22pm, Jesper Nygards wrote:
}
} I don't know if this is relevant, but I have some more findings. I wanted
} to know which sub directory was contributing the most to the amount of time
} taken to process the root directory. I then realized that the sum of the
} time it took to process each sub directory separately was much lower than
} processing the whole root directory at once.  [...]
} So obviously the processing time is not linear with the number
} of files.

Since exclusions are applied after globbing is completed, the processing
time for exclusions is proportional to the sum of the lengths of all the
file paths found by the recursive glob.  If you glob individual sub-
directories, you're not excluding based on the names of the container
directories.

E.g. you should find that

x=(**/*)
y=(${x:#(|*/)(build|target|node|node_modules|.idea|*.min.js|*.iml|TAGS)(|/*))

takes about the same amount of time as your **/*~pat formulation, and

x=(**/*(:t))
y=(${x:#(|*/)(build|target|node|node_modules|.idea|*.min.js|*.iml|TAGS)(|/*))

takes about the same amount of time as your loop over subdirs.

I still don't see a reason why pattern matching would have slowed down.

On the other hand, your pattern could be a lot more precise.  You have it
starting with (|*/) and ending with (|/*) which means that you do want to
exclude some directories, but obviously not all of the strings in the
middle are directory names.  If I were to guess that the directory names
are build, target, node, and node_modules, then things might go a lot
faster if you used

**/^(.idea|*.min.js|*.iml|TAGS)~(|*/)(build|target|node|node_modules)(|/*)

and even faster with

skipdirs() { reply=( ${REPLY%((build|target|node|node_modules)(|/*)} ) }

**/^(.idea|*.min.js|*.iml|TAGS)(+skipdirs)


  parent reply	other threads:[~2016-03-05 17:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-28 20:18 Jesper Nygårds
2016-02-29 19:12 ` Bart Schaefer
2016-03-01 11:39   ` Jesper Nygårds
2016-03-01 18:28     ` Bart Schaefer
2016-03-01 19:11       ` Jesper Nygårds
2016-03-02  0:03         ` Bart Schaefer
2016-03-02  8:39           ` Jesper Nygårds
2016-03-03  0:06             ` Bart Schaefer
2016-03-04  8:17               ` Jesper Nygårds
2016-03-04 13:22                 ` Jesper Nygårds
2016-03-04 14:03                   ` Peter Stephenson
2016-03-04 14:20                     ` Peter Stephenson
2016-03-04 21:49                       ` Peter Stephenson
2016-03-05 17:47                         ` Bart Schaefer
2016-03-06 18:10                           ` Peter Stephenson
2016-03-07  9:59                             ` Jesper Nygårds
2016-03-07 10:15                               ` Peter Stephenson
2016-03-05 17:37                   ` Bart Schaefer [this message]
2016-03-06 17:31                     ` Bart Schaefer
2016-03-21 23:05                       ` Bart Schaefer
2016-03-02  9:32           ` Peter Stephenson
2016-03-02 23:46             ` Bart Schaefer

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=160305093706.ZM22241@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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