Zsh Mailing List Archive
Messages sorted by:
Re: Re: High memory usage on // substitution in one situation, normal usage in other
- X-seq: zsh-workers 41135
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Re: High memory usage on // substitution in one situation, normal usage in other
- Date: Sun, 21 May 2017 16:43:22 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=/locbgmdNS9A5uhecpZY7qfQP0Y8v63BnMonAnwy9/4=; b=eWZsQ9AUaf2HkM/6NiQ2nnAroCBhMHUeuBo1HXV2jSsbamAlYEJIlLz9M/IxHGKYra hUiLu01f+GQqtxiUTbOKtTeqjVwTC/O2S0I4Q+1Mc4Qv1w0f+AH16YTcBOdPoDX0F0WF w+UogXDkPd+5FdKu7Lq9saBNxhojdHNzqRD9qsOmTG0cq/tpfFrcCzNJRgQv/7bvog4e vfLnErnVvqHPedM4DEKJlet58ZJY/4auVk2+BcDTtPZtMnS8AIGHCqwYqwV8bR6NHgXq dDditKttel92gdhGFIK2A1XgZNcwaTrniSgo8irKGxRHzVcNEtX7kuTmBEbRligx0nZI +p8Q==
- In-reply-to: <201705212227360937.046E4951@gateway.core.mpy.ch>
- List-help: <mailto:email@example.com>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <etPan.59214193.41a7c4c9.6b4c@MacMini.local> <170521130349.ZM4506@torch.brasslantern.com> <201705212227360937.046E4951@gateway.core.mpy.ch>
On May 21, 10:27pm, Manuel Presnitz wrote:
} I can reproduce the extraordinary high memory usage ...
} but only if EXTENDEDGLOB is set.
OK, that helps (and I should have caught that this is required for (#b)
to be meaningful).
Let's consider the two examples:
1) arr2 is an associative array mapping 200000 integers to underscores.
Flattened into a string, you get alternating number-strings and
underscores separated by spaces.
2) arr is an array of 900000 single underscores. Flattened it's a
string of underscores separated by spaces.
Now let's look more closely at the pattern:
Look at the rightmost $'...' expression: $'0\037'
That has a "0" character in it. Probably a typo, but it means that
every time there is a zero digit in $__text, the // recursion has to
save state before proceeding. This doesn't happen when the text is
nothng but underscores. The state that is being saved includes the
entire tail of the string from that point onward, so in the first
example it requires approximately 1.8MB/2*(the number of zeroes in
all integers from 1 to 200000), and in the second case it never does
recur (the ## consumes the entire string).
The memory is being allocated here:
* Array to record the start of characters for
VARARR(char, charstart, patinend-patinput);
memset(charstart, 0, patinend-patinput);
Messages sorted by: