From owner-freebsd-current@FreeBSD.ORG Sun Jul 8 02:04:17 2007 Return-Path: X-Original-To: freebsd-current@FreeBSD.org Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3C14C16A400; Sun, 8 Jul 2007 02:04:17 +0000 (UTC) (envelope-from scf@FreeBSD.org) Received: from mail.farley.org (farley.org [67.64.95.201]) by mx1.freebsd.org (Postfix) with ESMTP id CF2E513C465; Sun, 8 Jul 2007 02:04:16 +0000 (UTC) (envelope-from scf@FreeBSD.org) Received: from thor.farley.org (thor.farley.org [192.168.1.5]) by mail.farley.org (8.14.1/8.14.1) with ESMTP id l6825QYe084986; Sat, 7 Jul 2007 21:05:26 -0500 (CDT) (envelope-from scf@FreeBSD.org) Date: Sat, 7 Jul 2007 21:03:59 -0500 (CDT) From: "Sean C. Farley" To: Andrey Chernov In-Reply-To: <20070707191835.GA4368@nagual.pp.ru> Message-ID: <20070707205410.B14065@thor.farley.org> References: <20070704180000.GA34042@nagual.pp.ru> <20070704144159.X77978@thor.farley.org> <20070704195939.GA35302@nagual.pp.ru> <20070704235630.GA42227@nagual.pp.ru> <20070704215154.O77978@thor.farley.org> <20070705115816.GA50506@nagual.pp.ru> <20070705105922.F98700@thor.farley.org> <20070707130859.GA96605@nagual.pp.ru> <20070707131359.GB96605@nagual.pp.ru> <20070707133102.C14065@thor.farley.org> <20070707191835.GA4368@nagual.pp.ru> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.1 X-Spam-Checker-Version: SpamAssassin 3.2.1 (2007-05-02) on mail.farley.org Cc: freebsd-current , Robert Watson , Michal Mertl Subject: Re: Environment handling broken in /bin/sh with changes to {get,set,put}env() X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2007 02:04:17 -0000 On Sat, 7 Jul 2007, Andrey Chernov wrote: > On Sat, Jul 07, 2007 at 01:51:11PM -0500, Sean C. Farley wrote: >> I agree that it would be faster for a subset of an existing environ. >> On the other hand, in the case of emptying the environment, my method >> would be faster since no deallocation, allocation nor setenv() calls >> would be called assuming putenv() was not used. I could try a few >> tests to see what is faster in which case, but I do not think environ >> changes happen often enough to make speed a factor. > > Well, lets go with that. I ran the tests out of curiosity. All code is here[1]. The dropping was effectively freeing envVars and the environ that getenv.c creates for the program. All other counters were set to zero. The first test (timing-clear.c) cleared the environment by swapping two char ** arrays containing a single NULL pointer. 500000 iterations. x drop/clear-timings.txt + keep/clear-timings.txt N Min Max Median Avg Stddev x 50 1.634899 1.672082 1.656838 1.6567984 0.0093033009 + 50 1.326203 1.348855 1.3296575 1.3323876 0.0062632107 Difference at 95.0% confidence -0.324411 +/- 0.00314674 -19.5806% +/- 0.189929% (Student's t, pooled s = 0.0079303) The second test (timing-merge.c) swapped two duplicates of my environment over 5000 iterations. x drop/merge-timings.txt + keep/merge-timings.txt N Min Max Median Avg Stddev x 50 1.337052 1.406142 1.3663635 1.3634524 0.015210835 + 50 0.889559 0.913354 0.8943785 0.89644634 0.0056274351 Difference at 95.0% confidence -0.467006 +/- 0.00455057 -34.2517% +/- 0.333753% (Student's t, pooled s = 0.0114682) Surprisingly, keeping the pointers saved time even if calling setenv(). Sean 1. http://www.farley.org/freebsd/tmp/setenv/clearenv/ -- scf@FreeBSD.org