From owner-freebsd-hackers@FreeBSD.ORG Tue May 6 12:35:02 2008 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 90C071065676 for ; Tue, 6 May 2008 12:35:02 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.230]) by mx1.freebsd.org (Postfix) with ESMTP id 691728FC29 for ; Tue, 6 May 2008 12:35:02 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by rv-out-0506.google.com with SMTP id b25so571057rvf.43 for ; Tue, 06 May 2008 05:35:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=aB2+AbWRhUTlOJDFNcHno97MFQ//hByY5o5uw5rBwu8=; b=DDgMYLakHdyNZQ5ZXDxTVS+zD7OgrkGIUTRLanVUxavTKb5uWoGATyHkXiCWSYIiBLuwasbn5qd1ASu/akGLeRnF3PF6mbTRi1A68oAsEALHNvB2YMBGJ8/KtmFJJ1UvSW3LOMrdUr62Rfpv4LLfU2XBJtZHEhZ49TWc12OTqxE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=Zs/uPQi/ZtURd/c9dCAq0l5dn14iOp1ttImaH8VrJpshXFYYWUjOO1AzuJzp0td3kaNf4H+XrKBYSu+N6MqxMLXyg/4CVYD7vgQ4bwTCAORTp4olBFwFPYlBQmdJG8dRIFx0/462F8Rvf8tfjL5Z8glIlxcShYVKQdxCIdQD54Y= Received: by 10.141.35.21 with SMTP id n21mr308544rvj.115.1210075706115; Tue, 06 May 2008 05:08:26 -0700 (PDT) Received: by 10.140.143.14 with HTTP; Tue, 6 May 2008 05:08:26 -0700 (PDT) Message-ID: Date: Tue, 6 May 2008 20:08:26 +0800 From: "Adrian Chadd" Sender: adrian.chadd@gmail.com To: "Roman Divacky" In-Reply-To: <20080506074830.GA70848@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080505204350.GA45321@freebsd.org> <20080506062556.GA68171@zim.MIT.EDU> <20080506074830.GA70848@freebsd.org> X-Google-Sender-Auth: d5bb803b53c6ad68 Cc: hackers@freebsd.org Subject: Re: hashinit versus phashinit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 May 2008 12:35:02 -0000 2008/5/6 Roman Divacky : > > Most general-purpose hash implementations I've used (e.g., GNU > > libstdc++, Sun JDK, Microsoft .NET) use prime table sizes, > > probably to make it less likely that programmers will shoot > > themselves in the foot with pathological data or bad hash functions. > > yes... a division takes roughly 40 cycles on modern i386 hw, while > and is just 1, but does it matter compared to the access times of > memory these days? > > the ratio between cpu-speed/mem-speed has changed a lot. I am not > arguing if it's still true that avoiding the division helps the performance > these days... My 2c - I'd poke the assembler, a book or two on current architectures, and combine it with some benchmarking followed by logical reasoning. Modern microprocessors don't execute instructions like they used to before I was born; "divide versus logical shift/operator" speed may be secondary to pipeline and IU effects, memory access (as mentioned before), etc. (I know its not much - but I'm a firm believer in "Science!", and this is one of those questions which can be understood with a little bit of it..) Adrian -- Adrian Chadd - adrian@freebsd.org