[Mono-dev] SHA1Managed speedups

Sebastien Pouliot sebastien.pouliot at gmail.com
Tue Apr 29 19:40:14 EDT 2008


Great work! The IL size is also down by a good margin so everybody
wins :-)

Please go ahead and commit (after testing and adding changelogs)

Thanks
Sebastien

On Tue, 2008-04-29 at 23:52 +0100, Alan McGovern wrote:
> 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.
> >  
> 



More information about the Mono-devel-list mailing list