From owner-cvs-src-old@FreeBSD.ORG Fri Mar 12 21:15:13 2010 Return-Path: Delivered-To: cvs-src-old@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6BE9E106564A for ; Fri, 12 Mar 2010 21:15:13 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 5BB328FC12 for ; Fri, 12 Mar 2010 21:15:13 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o2CLFD6p020428 for ; Fri, 12 Mar 2010 21:15:13 GMT (envelope-from delphij@repoman.freebsd.org) Received: (from svn2cvs@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o2CLFDI0020427 for cvs-src-old@freebsd.org; Fri, 12 Mar 2010 21:15:13 GMT (envelope-from delphij@repoman.freebsd.org) Message-Id: <201003122115.o2CLFDI0020427@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: svn2cvs set sender to delphij@repoman.freebsd.org using -f From: Xin LI Date: Fri, 12 Mar 2010 21:14:56 +0000 (UTC) To: cvs-src-old@freebsd.org X-FreeBSD-CVS-Branch: HEAD Subject: cvs commit: src/lib/libc/string strlen.c X-BeenThere: cvs-src-old@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: **OBSOLETE** CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Mar 2010 21:15:13 -0000 delphij 2010-03-12 21:14:56 UTC FreeBSD src repository Modified files: lib/libc/string strlen.c Log: SVN rev 205099 on 2010-03-12 21:14:56Z by delphij Two optimizations to MI strlen(3) inspired by David S. Miller's blog posting [1]. - Use word-sized test for unaligned pointer before working the hard way. Memory page boundary is always integral multiple of a word alignment boundary. Therefore, if we can access memory referenced by pointer p, then (p & ~word mask) must be also accessible. - Better utilization of multi-issue processor's ability of concurrency. The previous implementation utilized a formular that must be executed sequentially. However, the ~, & and - operations can actually be caculated at the same time when the operand were different and unrelated. The original Hacker's Delight formular also offered consistent performance regardless whether the input would contain characters with their highest-bit set, as it catches real nul characters only. These two optimizations has shown further improvements over the previous implementation on microbenchmarks on i386 and amd64 CPU including Pentium 4, Core Duo 2 and i7. [1] http://vger.kernel.org/~davem/cgi-bin/blog.cgi/2010/03/08#strlen_1 MFC after: 1 month Revision Changes Path 1.8 +31 -12 src/lib/libc/string/strlen.c