From owner-svn-src-head@FreeBSD.ORG Fri Oct 1 21:47:05 2010 Return-Path: Delivered-To: svn-src-head@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 56AC01065675; Fri, 1 Oct 2010 21:47:05 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from tarsier.geekcn.org (tarsier.geekcn.org [IPv6:2001:470:a803::1]) by mx1.freebsd.org (Postfix) with ESMTP id BC1868FC1A; Fri, 1 Oct 2010 21:47:04 +0000 (UTC) Received: from mail.geekcn.org (tarsier.geekcn.org [211.166.10.233]) by tarsier.geekcn.org (Postfix) with ESMTP id CE874A6B2EF; Sat, 2 Oct 2010 05:47:03 +0800 (CST) X-Virus-Scanned: amavisd-new at geekcn.org Received: from tarsier.geekcn.org ([211.166.10.233]) by mail.geekcn.org (mail.geekcn.org [211.166.10.233]) (amavisd-new, port 10024) with LMTP id Gjhi5ddNlqlF; Sat, 2 Oct 2010 05:46:58 +0800 (CST) Received: from delta.delphij.net (drawbridge.ixsystems.com [206.40.55.65]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tarsier.geekcn.org (Postfix) with ESMTPSA id B5C9BA6B322; Sat, 2 Oct 2010 05:46:56 +0800 (CST) DomainKey-Signature: a=rsa-sha1; s=default; d=delphij.net; c=nofws; q=dns; h=message-id:date:from:reply-to:organization:user-agent: mime-version:to:cc:subject:references:in-reply-to: x-enigmail-version:openpgp:content-type:content-transfer-encoding; b=PCu8byz5/52vC6Jpne1Z7EJZfbWsSGhHmeUwb2hPDI0/mcRUXRvt/qvkedcIsD388 JxU2w9cAmzGDzqggvrD9Q== Message-ID: <4CA656CD.40908@delphij.net> Date: Fri, 01 Oct 2010 14:46:53 -0700 From: Xin LI Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.1.12) Gecko/20100920 Thunderbird/3.0.8 ThunderBrowse/3.3.2 MIME-Version: 1.0 To: Roman Divacky References: <201010011310.o91DABUU007534@svn.freebsd.org> <20101001132233.GA83116@freebsd.org> In-Reply-To: <20101001132233.GA83116@freebsd.org> X-Enigmail-Version: 1.0.1 OpenPGP: id=3FCA37C1; url=http://www.delphij.net/delphij.asc Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Jilles Tjoelker , svn-src-head@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, src-committers@FreeBSD.ORG Subject: Re: svn commit: r213326 - head/lib/libc/i386/string X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: d@delphij.net List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Oct 2010 21:47:05 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 2010/10/01 06:22, Roman Divacky wrote: > On Fri, Oct 01, 2010 at 01:10:11PM +0000, Jilles Tjoelker wrote: >> Author: jilles >> Date: Fri Oct 1 13:10:11 2010 >> New Revision: 213326 >> URL: http://svn.freebsd.org/changeset/base/213326 >> >> Log: >> libc: Remove the i386 assembler version of strlen(3). >> >> On anything modern, the C version, which processes a word at a time, is much >> faster. The Intel optimization manual explicitly warns against using REP >> prefixes with SCAS or CMPS, which is exactly what the assembler version >> does. > > there's "rep cmps" in bcmp.S and memcmp.S in both amd64/i386 > > they both have C counterparts, no idea how fast those are (they > are going char by char). char by char will be slower than word-by-word in both aligned and unaligned case. There are some other factors like inline expanding, etc. which also affects their speed and require careful tuning. > does this wisdom apply to those too? I'm not quite sure about bcmp() and memcmp() case, especially when the two pointers are not aligned (say, (p1 & (sizeof(word)-1)) != (p2 & (sizeof(word)-1))). Branching for different aligning cases MAY give better performance, BUT they can also hurt due to the added complexity, so if we want to do it in a MI way we will need to benchmark. === By the way I have a memchr(3) implementation using the similar algorithm strlen(3) uses, and microbenchmark shows a 2x to 3x improvement but it's still in my queue and needs to do real-world testing. Cheers, - -- Xin LI http://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (FreeBSD) iQEcBAEBCAAGBQJMplbNAAoJEATO+BI/yjfBgWwH/2MSNvH0QNhEcyhKBU/Pzh8C 862myDjcxA4l1+ca2en9igPgWno+ZMUaiH4Td5qCBdX8tsFLlGCgC0o0a0HC51+7 mv8qTfWrYAFcU2NrmX8wsnprLijmS2NH3wBC0uJJXpJhmJUraTHbG9YcctIUe363 Yvy+d7HqraPvCShWEgj54V5q/vPPy5vT6gPFwhMpe0J9/gmSMwwxCF1RctE2K/Br 89TWb/g4vrFJCk3Ks3j8viJJN2Zd9sbBYeF/LBnMLPkVSJNCnw0j1gSs+uFbfgzw Gv5WMNNpDu338dFMVJDddgxqWa+OW1oMgtHcLUmoxMQI87sir+NJQFBD6+EK22I= =2+Hh -----END PGP SIGNATURE-----