Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14491 > unrolled thread

Re: Unexpected delay in using arguments.

Started byBize Ma <binaryzebra@gmail.com>
First post2018-08-14 23:17 -0400
Last post2018-08-14 23:17 -0400
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Unexpected delay in using arguments. Bize Ma <binaryzebra@gmail.com> - 2018-08-14 23:17 -0400

#14491 — Re: Unexpected delay in using arguments.

FromBize Ma <binaryzebra@gmail.com>
Date2018-08-14 23:17 -0400
SubjectRe: Unexpected delay in using arguments.
Message-ID<mailman.5124.1534303082.1292.bug-bash@gnu.org>
> Of course I assume this is only a proxy simpler reproducer
> for the actual problem program

Of course this is a "reproducer" of the issue.

> but just the same it is almost always possible
> to refactor a program into a different algorithm that avoids the need
> to enumerate so many arguments in memory.

As you say: "almost".

Take a look at the Stéphane Chazelas example to convince yourself.



2018-08-14 17:50 GMT-04:00 Bob Proulx <bob@proulx.com>:

> I followed along through the script:
>
> >     m=20000
> ...
> >     test1() { ...
>
> Eventually I got to this line:
>
> >       set -- $(seq $m)
>
> At that line I see that bash must allocate enough memory to hold all
> of the numbers from 1 through 20000 in memory all at one time.  That
> is very inefficient.  That is at least 100K of memory.
>
>   $ seq 20000 | wc -c
>   108894
>
> Of course I assume this is only a proxy simpler reproducer for the
> actual problem program but just the same it is almost always possible
> to refactor a program into a different algorithm that avoids the need
> to enumerate so many arguments in memory.  I suggest refactoring the
> program to avoid the need for this memory stress.
>
> Bob
>

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web