[hashcash] Re: Hashcash performance improvements

  • From: Jonathan Morton <chromi@xxxxxxxxxxxxxxxxxxxxx>
  • To: hashcash@xxxxxxxxxxxxx
  • Date: Wed, 26 May 2004 14:55:25 +0100

>> I recently sent Adam an updated version of libsha1.c, which is about
>> 20% faster on x86 machines.  After some more thought in this vein, I'd
>> like to help write a set of "fast minting" routines which maximise
>> sustained minting performance on a given class of machines.

> I'd be happy to incorporate those changes in the next version.
>
> Re. fast SHA1 assembler tricks with MMX etc, if I recall there are some
> people who have researched this and made some progress.  I think some 
> of
> their source is available (some not).  You could have a look for that.

Sounds encouraging.  I think I at least need some pointers on how to 
portably insert MMX assembly into a C program - I'm presently assuming 
it's slightly more involved than inserting Altivec operations (which 
Motorola went to a great deal of trouble to make easy).  At the very 
least, I'm aware of two completely incompatible assembler syntaxes for 
x86 (GNU vs. Intel - the difference is operand order), so for the 
moment I'll concentrate heavily on GCC syntax.

In the interim, I've done some profiling of the present hashcash 
implementation on PowerPC, and discovered to my horror that under 
2/3rds of the minting time (597 out of 904 cycles on the PPC7400 
emulator, slightly worse still on a real PPC7450) was spent in the body 
of the SHA1_Transform() function.

Eliminating the huge overhead that this reveals would result in a 50% 
performance boost, even with no CPU-specific optimisations.  (Probably 
less on x86, since the hashing function takes relatively longer there, 
but still significant.)  I'll work on refactoring first, in that light, 
and worry about vectorised code later.

Since you seem to be in the middle of reworking the token formatting, 
I'll leave that part of the hashcash program alone, and merely provide 
an entry point, along with an example/test program for usage.

--------------------------------------------------------------
from:     Jonathan "Chromatix" Morton
mail:     chromi@xxxxxxxxxxxxxxxxxxxxx
website:  http://www.chromatix.uklinux.net/
tagline:  The key to knowledge is not to rely on people to teach you it.


Other related posts: