On Thu, Jan 10, 2002 at 09:34:14PM +0100, Niklas Mehner wrote:
> Scott G. Miller wrote:
> 
> >
> >My only comment is that the code in TwofishAlgorithm was designed to be
> >inlined by the JVM at Runtime, so yes, it should improve startup
> >performance considerably, but it should actually worsen performance over
> >time.  
> >
> If you look at the test-case-code, you'll see that the methods get 
> called 2000000 times, before the time is taken, so any inlining should 
> have been made by then.
> 
> >The reason is that after inlining, this becomes a JVM tableswitch
> >operation followed by a constant shift and bitmask.  Further optimization
> >may even get rid of the tableswitch depending on JVM.
> >
> Whereas my method becomes some 4 asm instructions. I do not really know 
> what kind of optimizations, the JVMs do, besides method inlining / 
> compiling to native code, but I guess, that any branching instruction 
> (which the tableswitch is) is always much slower than simple arithmetic 
> instructions.
Probably true.  

> 
> But to cut this discussion short: I looked into the code some more and 
> realized, that R can only be 0 or 3. So I replaced the method with 2 
> methods and optimized some more. This way only 2 operations are needed, 
> to calculate the value of 2*_b() ...
R can only be 0 or 3?  In our code perhaps.

> 
> The code seems to work, but since errors in encryption are hard to trace 
> later, I'll do some more tests and performance evaluation tomorrow ... 
> (if you are interested in including it ...)

Definitely interested.  Make sure you test one with the optimizations and
one without together.  Also, you can try the included Monte Carlo tests.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20020110/1b5b47e3/attachment.pgp>

Reply via email to