git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Giuseppe Scrivano <gscrivano@gnu.org>
Cc: Bug-coreutils@gnu.org, "Pádraig Brady" <P@draigBrady.com>,
	"Git Mailing List" <git@vger.kernel.org>
Subject: Re: Linus' sha1 is much faster!
Date: Sun, 16 Aug 2009 15:47:08 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.01.0908161539300.3162@localhost.localdomain> (raw)
In-Reply-To: <87ab1ze76y.fsf@master.homenet>



On Mon, 17 Aug 2009, Giuseppe Scrivano wrote:
> 
> Thanks for the hint.  I tried gcc-4.4 and it produces slower code than
> 4.3 on the gnulib SHA1 implementation and my patch makes it even more!

Check out the asm, see if you can see why. One of the most common problems 
with P4's is literally that you end up loading from the same stack slot 
that you just stored to (gcc can do some really crazy spills), and that 
causes a store buffer hazard replay.

My personal opinion is that Netburst is useless for trying to optimize C 
code for. It's just too random.

> I noticed that on my machine your implementation is ~30-40% faster using
> SHA_ROT for rol/ror instructions than inline assembly, at least with the
> test-case Pádraig wrote.  Am I the only one reporting it?

I bet it's the same thing. Small perturbations of the source causing small 
changes to register allocation and thus spilling, and then Netburst goes 
crazy one way or another. It's interestign trying to fix it, and very 
frustrating.

My workstation is a Nehalem (but Core 2 will have pretty much the same 
behavior), and it doesn't have the crazy netburst behavior. Shorter and 
simpler code generally performs better (which is _not_ true on Netburst). 

On my machine, for example, forcing gcc to do those rotates on registers 
is the difference between ~381MB/s and 415MB/s. And that's mainly because 
it makes gcc keep A-E in registers, rather than trying to cache the 
array[] references.

			Linus

  reply	other threads:[~2009-08-16 22:48 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-14 23:25 Linus' sha1 is much faster! Pádraig Brady
2009-08-15 20:02 ` Bryan Donlan
2009-08-15 20:12   ` John Tapsell
2009-08-15 20:23     ` Linus Torvalds
2009-08-15 20:54       ` Linus Torvalds
2009-08-17  1:55         ` Nicolas Pitre
2009-08-26 11:39           ` Pádraig Brady
2017-04-20 21:35             ` galt
2017-04-20 21:38             ` galt
2009-08-17  8:22         ` Andreas Ericsson
2009-08-16  0:06     ` Theodore Tso
2009-08-16 19:25 ` Giuseppe Scrivano
2009-08-16 20:10   ` Linus Torvalds
2009-08-16 22:15     ` Giuseppe Scrivano
2009-08-16 22:47       ` Linus Torvalds [this message]
2009-08-17  1:53   ` Pádraig Brady
2009-08-17 10:51     ` Giuseppe Scrivano
2009-08-17 15:44       ` Steven Noonan
2009-08-17 16:22         ` Linus Torvalds
2009-08-17 21:43           ` Steven Noonan
2009-08-17 17:32         ` Giuseppe Scrivano
  -- strict thread matches above, loose matches on Subject: below --
2009-08-17  7:23 George Spelvin
2009-08-17 14:20 ` Nicolas Pitre
2009-08-17 17:06 ` Nicolas Pitre
2009-08-17 17:20   ` Paolo Bonzini
2009-08-17 18:54   ` George Spelvin
2009-08-17 19:34     ` Nicolas Pitre
2009-08-17 23:12       ` George Spelvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.01.0908161539300.3162@localhost.localdomain \
    --to=torvalds@linux-foundation.org \
    --cc=Bug-coreutils@gnu.org \
    --cc=P@draigBrady.com \
    --cc=git@vger.kernel.org \
    --cc=gscrivano@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).