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


Groups > gnu.bash.bug > #14488

Re: Unexpected delay in using arguments.

From Stephane Chazelas <stephane.chazelas@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: Unexpected delay in using arguments.
Date 2018-08-14 23:21 +0100
Message-ID <mailman.5111.1534285326.1292.bug-bash@gnu.org> (permalink)
References <CAFra36j=UuqHv2Spp26ebAW0dRW+KsgNS21hZJrwuku9QUayWw@mail.gmail.com> <mailman.5096.1534260312.1292.bug-bash@gnu.org>

Show all headers | View raw


2018-08-14 11:25:04 -0400, Chet Ramey:
[...]
> 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, since you have
> to save and restore it each time you call f1. Looking at making that more
> efficient has been a low-level task for a while now.
[...]

To save and restore that list of arguments, you only need to
save and restore one pointer. I don't see why you'd need to copy
the full list of pointers let alone the text of the arguments.

Note that it makes scripts using functions and that receive a
large number of arguments (think of scripts called as find .
-exec myscript {} + for instance) terribly inefficient.

find / -xdev -exec bash -c 'f(){ :;}; for i do f; done' bash {} +

(do nothing in a function for all the files in my root file
system) takes 4 seconds in dash and 9 minutes (135 times as
much) in bash.

-- 
Stephane

Back to gnu.bash.bug | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: Unexpected delay in using arguments. Chet Ramey <chet.ramey@case.edu> - 2018-08-14 11:25 -0400
  Re: Unexpected delay in using arguments. Stephane Chazelas <stephane.chazelas@gmail.com> - 2018-08-14 23:21 +0100

csiph-web