Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Stephane Chazelas Newsgroups: gnu.bash.bug Subject: Re: Unexpected delay in using arguments. Date: Tue, 14 Aug 2018 23:21:58 +0100 Lines: 25 Approved: bug-bash@gnu.org Message-ID: References: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: usenet.stanford.edu 1534285327 13103 208.118.235.17 (14 Aug 2018 22:22:07 GMT) X-Complaints-To: action@cs.stanford.edu Cc: Bize Ma , bug-bash To: Chet Ramey Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=gkeibmip4IlKa+cfoeXVRdWEBNPqx5sgoG/hWPHovmo=; b=EvUFxWTr9WZYTlrmg0UkVhK9u8fpwttelSzSEUBh86ljY4A2FiMlc7FUWBzdNbzhsg XVhLdKDZcUkvLpJzXsqgu2NYnjAGQ/gTMHx262JI1wxhUCCz/g4XcovhQsNITlMRc6o2 2llDsRO82ljkszfRu5QkHp7dUwyr2nXAi9xxM5bgUdsZlWgWEqvdOo8i2v3Wa7hOMkSA UztodOLvtxLw5mOuwcZXBb/wpjElP1g/u7hb8JBS0K6D2uHWaRHcU1pdZO5smVxzc3Ks y0KegEUHoJyrwZ3PxPfj9AVur1q89ZvQDwpoLhIFnDVW+pBhiXEyW+IyXfhX8CAsgIT/ mNRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=gkeibmip4IlKa+cfoeXVRdWEBNPqx5sgoG/hWPHovmo=; b=Ifa8Po/mbelRKDYnNGMeZMQChEcJuQIVLHhi2qRc+cj8FQ9Ou9W4xy57lXapR4r6RC qTA5boKD/QXpPBW8iBdv/FiUsMwanS26+r/afbfCwapXBdIFtBtDHaK9+jHbJgZX651s iVzz0+jVw02i4kLsdY3SylsN4lFhIWRsxp3/wwnZFS/lpUako228CD8ueESPanHzJA9X y0sE0uOcaw2wS3PI+ZmqUgU9xgiFYtWNeY37CzVhxyWUVO9IXFIkcI0ORy19wfMDaZNf 5fKLnMVtw3pJnzDMOOroyVKAGwujeODQhzPvghcJtzy85WjTP+b1PZhxh2R0+qoG/Jwj SrHw== X-Gm-Message-State: AOUpUlFmlpjofFEMQ30iaeDvPW1bNfYA54gzYxwjgHFEp439Y5GRwPLV KJMiUhiLFQtsLtaoTOAvL5s= X-Google-Smtp-Source: AA+uWPzO2yxaQZf3ck+cJeDpoJoVg+HR9aL4aRGGYQEtOVbvWJdnwO1j/x6NgBKhRu6kvyyqbDMFyw== X-Received: by 2002:a1c:5f82:: with SMTP id t124-v6mr12205811wmb.14.1534285319861; Tue, 14 Aug 2018 15:21:59 -0700 (PDT) Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22d 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:14488 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