From owner-freebsd-arch@FreeBSD.ORG Thu May 10 23:57:54 2007 Return-Path: X-Original-To: arch@FreeBSD.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3CA7016A400; Thu, 10 May 2007 23:57:54 +0000 (UTC) (envelope-from sean-freebsd@farley.org) Received: from mail.farley.org (farley.org [67.64.95.201]) by mx1.freebsd.org (Postfix) with ESMTP id CFDC813C43E; Thu, 10 May 2007 23:57:53 +0000 (UTC) (envelope-from sean-freebsd@farley.org) Received: from [192.168.1.211] ([192.168.1.211]) by mail.farley.org (8.14.1/8.14.1) with ESMTP id l4ANxGLI049852; Thu, 10 May 2007 18:59:23 -0500 (CDT) (envelope-from sean-freebsd@farley.org) Date: Thu, 10 May 2007 18:58:45 -0500 (CDT) From: "Sean C. Farley" To: Bruce Evans In-Reply-To: <20070509200000.B56490@besplex.bde.org> Message-ID: <20070510184447.H4969@baba.farley.org> References: <20070502230413.Y30614@thor.farley.org> <20070503160351.GA15008@nagual.pp.ru> <20070504085905.J39482@thor.farley.org> <20070504213312.GA33163@nagual.pp.ru> <20070504174657.D1343@thor.farley.org> <20070505213202.GA49925@nagual.pp.ru> <20070505163707.J6670@thor.farley.org> <20070505221125.GA50439@nagual.pp.ru> <20070506091835.A43775@besplex.bde.org> <20070508162458.G6015@baba.farley.org> <20070508222521.GA59534@nagual.pp.ru> <20070509200000.B56490@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Daniel Eischen , arch@FreeBSD.org, Andrey Chernov Subject: Re: HEADS DOWN X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 May 2007 23:57:54 -0000 On Wed, 9 May 2007, Bruce Evans wrote: > On Wed, 9 May 2007, Andrey Chernov wrote: > >> On Tue, May 08, 2007 at 04:37:03PM -0500, Sean C. Farley wrote: >>> Would it be preferred to go ahead to use strlen() in preparation >>> for a faster strlen() in the future? >> ... >> we can use strlen() in preparation for the future. > > Yes, it is better to use library functions if they do (almost) exactly > what is wanted. > >>> I would still use the inline'd version when counting characters >>> while watching for an '=' character. Or should it also be changed >>> to perform a strlen() and then a strchr()? >> >> Combined strlen()+strchr() will be slower in any case than single >> loop, so better leave it as is. > > The compiler could in theory reduce to a single loop, but I've never > seen one that does and would use the loop myself. I changed the code[1] to use strlen() and strncmp() instead of some of my hand-built functions while keeping the strlen() + '=' function. Would there be any other changes anybody can see need to be made? What type of testing would be desired? The regression tests I wrote provide a good basic test. In an attempt to make strlen() faster, I wrote a new strlen()[2] that performs a trick to boost performance by searching by word then by byte within a word to find the NUL byte. It did not compare to the speed of the built-in strlen() in GCC, but it is twice as fast as lib/libc/string/strlen.c. It was hard to really compare due to the built-in code as well as what __pure does. __pure seemed to make all versions the same speed. At some times, I really did not know for certain which version (assembly, builtin, original, new) of strlen() I was testing. :) Sean 1. http://www.farley.org/freebsd/tmp/setenv-8/POSIX/sysenv-strlen.c 2. http://www.farley.org/freebsd/tmp/strlen.c -- sean-freebsd@farley.org