Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Bize Ma Newsgroups: gnu.bash.bug Subject: Re: Unexpected delay in using arguments. Date: Tue, 14 Aug 2018 23:00:22 -0400 Lines: 40 Approved: bug-bash@gnu.org Message-ID: References: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: usenet.stanford.edu 1534302029 20687 208.118.235.17 (15 Aug 2018 03:00:29 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash To: Chester Ramey Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=4f8tmYzCf7FN4R/5w4xoAIZ1PVUVuJ7yvliFT90GfA4=; b=CY7aqyUtyj+E28l07Lgkz7FsVLdCUf3D59784jAiTdO07NDpW4QFktcOM4VGt3JNuo CiSy3PWtAVOdH0gTDOmNmOpNdyPmZwqqPHdACg0gl31b+WGSeCkZ3b8mxF6iItRHAN+p KaH3jyMl7gKVGuf2zd2VSsv66Fw6uokOIMu8NoNq3XQL3Ob5WoeJiwHhlEyStm1ZLv3I +4s1M1Pn12vnLhOAp0feMIf5HWBAowNZYAigIL3ke+sWn5lJKG84CSWvMB7mADNYJIkw z3S+unB9qG2UjN82/k7MX5cz/HOIWQOnUTTQHc+eRs2xggEWtiDjdRudZwuSkKkbILWV 3TJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=4f8tmYzCf7FN4R/5w4xoAIZ1PVUVuJ7yvliFT90GfA4=; b=TYXyxgaTfEp0P+yslQs3n7pgX1Dxcc6xqTCp6DKYahUlS1pyhJl/KYnG5elgnpSUvO B5L6K8Q+z7RQsMxUAccLFaR+WRIAgqn0+bizdg4xFLzfiL0dHY5c4H/3SxCkME40DVKX hmVD+8N4RPaGmRASC7i30k+Qnis7Oj+dkk9OpHD4bvJQknFG/ZIFubVpzE6XW6a5jU/b c7Iub2f053OfLshktaKpUo9DCuxvxQFDXrXDdEHEpTsV0U9wYz4rLGwMsR/0EqO37yI7 XeKspyA8gtc0H5Hdy3KLuvxmxTeZgjjfPljQxkmmAFIC2qaehkUEsxR8OSibg5n0Z7ng /ggQ== X-Gm-Message-State: AOUpUlFGilKeI0wMrn7gMKrLN7e3hbf5Zczp/cvtAV5qjawAwTdSXwus 7smBp1vV8Y1+dEVvBc259O1YhAIh+EpJvm8n8Eo= X-Google-Smtp-Source: AA+uWPxL5bSrZxAQlnuWqlRiyr/ul5BrdeiCEDJ88VbJTM/G1Akamjh6hULWrmsVqn7+i3kwGHRFX4SI5kzDdDW+PNA= X-Received: by 2002:aca:ec51:: with SMTP id k78-v6mr24208284oih.236.1534302022730; Tue, 14 Aug 2018 20:00:22 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22f X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14490 2018-08-14 11:25 GMT-04:00 Chet Ramey : > 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.