Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Extended globbing seems to have become much slower in recent versions of Zsh

On Fri, 4 Mar 2016 14:03:42 +0000
Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> - Memory management associated with multiple directories; could be
> allocation or heap management.

I'm forgetting it's not simply speed of glob/pattern code, it's speed of
certain forms of glob/pattern code.  So tree structure problems don't
really fit.

Another possible clue here: the exclusion modifiers require additional
allocations when running the platform --- see line 3037 of pattern.c
(there's another one later).  This is currently permanently rather than
heap allocated.  It's easy to change to heap, but I wouldn't suggest
that --- with any kind of complicated backtracking this would eat memory
like there's no tomorrow.

It would be possible to use local pools of memory for this, however, so
it didn't get allocated and freed every single time it was needed.  I
think we only need one allocation for each occurrence of an exclusion,
and usually there are very few in a pattern, so this isn't hard to
manage. This might be an optimisation worth having anyway.

Although this hasn't changed significantly since I put the pattern code
in roughly its current form *many* years ago, 1999 apparently, it's
hairy enough that it's quite possible it could trip over pathologies in
interacting with the system and libraries.

(So brainstorming wasn't quite so futile after all...)


Messages sorted by: Reverse Date, Date, Thread, Author