[Mono-dev] SHA1Managed speedups

Alan McGovern alan.mcgovern at gmail.com
Tue Apr 29 18:52:31 EDT 2008


Ok, so here's the latest and greatest.

I've attached a new patch for the managed SHA1 implementation. One loop is
fully unrolled (InitialiseBuffer), one is partially unrolled (FillBuff) and
i rolled up the SHA1 calculations as much as i think is possible. This means
the cs file has gone from 500 lines to 330 lines. This should make JITing
faster, which was one concern raised earlier. The reason for leaving
InitialiseBuffer unrolled is that it gave a fairly dramatic increase in
speed. Also, it's quite short as compared to the other two methods, so there
wouldn't be a huge LOC saving if i rolled it up, but there would be a
noticeable perf. loss.

Now, performance! The attached testbench.cs file can be compiled and run by
itself. It will then print out timing for the SVN-head version of the SHA1
algo and the enhanced version of the algo. The results i've gathered so far
are:

Core Duo @ 1.86GHz
SVN     : 8004ms
Enhanced: 6007ms
*1.33x faster*

Core 2 Duo @ 2.40GHz
SVN     : 6062ms
Enhanced: 3945ms
*1.53x faster*

Finally, a version of the above code where all the loops are fully unrolled
is only about 1.06x faster, so the perf loss in rolling up those two loops
is fairly negligible.

Let me know your thoughts on this,

Alan.

On Tue, Apr 29, 2008 at 7:25 PM, Alan McGovern <alan.mcgovern at gmail.com>
wrote:
> Hi igor,
>
>
>  >  [1] The first numbers from Alan, on Sunday using unsafe code, were
>  >  around 40% and he made more progress after that.
>  The current unsafe code version is just over 3x faster than the
>  default implementation in Mono 1.9. However this will never be
>  committed to mono itself. So don't get your hopes up on it ;)
>
>
>  >  I committed (i.e.it's already in HEAD) a small patch to helps ABC
removal (fields versus
>  >  local). This gained (well reduced time by) 26% on a P4 (x86 JIT). The
next day I tried th
>
> >  same code on a 64 bit box (x86_64 JIT) and the time reduction was 32%.
>
>  My current working version using safe code only is about twice as fast
>  as Mono 1.9. It includes the patch mentioned above by sebastien. This
>  is the patch included in my first email. However, there is the issue
>  that this makes the SHA1 class a bit of a monster for the JIT. I'm
>  going to see if i can reduce the size of the class without losing too
>  much of the extra performance. So check back later tonight for exact
>  numbers and my testbench.
>
>  Alan.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080429/42606dc8/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: crypto.patch
Type: text/x-diff
Size: 16453 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080429/42606dc8/attachment-0001.bin 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: testbench.cs
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080429/42606dc8/attachment-0001.pl 


More information about the Mono-devel-list mailing list