[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unexpected delay in using arguments.
From: |
Bize Ma |
Subject: |
Re: Unexpected delay in using arguments. |
Date: |
Tue, 14 Aug 2018 23:00:22 -0400 |
2018-08-14 11:25 GMT-04:00 Chet Ramey <chet.ramey@case.edu>:
> On 8/12/18 3:16 AM, Bize Ma wrote:
> > Try this script:
> (...)
> Which is a thousand times slower.
>
> If you build a profiling version of bash, you'll find that about 75% of
> that time is spent copying the list of arguments around
I just don't see why there is any need to copy arguments.
Most other shells seem that they don't do that.
> , since you have
> to save and restore it each time you call f1.
There is no need to "copy", that just waste additional memory.
Just point to a new list of arguments (it is a change of only a memory
pointer).
Release the memory when the argument list is not being used any more.
> > Bash 5 is even worse, try:
>
> Bash-5.0-alpha is not a released version, so it uses the debugging malloc.
> If you profile that, you'll find that about 99% of the time is spent
> marking allocations as active and free in the table the bash malloc uses
> to keep track of active memory.
>
Yes, tests with "--without-bash-malloc" and "RELSTATUS=release" were done
after I posted the OP.
Yes, version 5.0 is not corrected, and looks that it is not "worse".
Sorry for the misrepresentation.