ThirtyTwoBitRegister

Jason Dufair jase at dufair.org
Sun May 16 14:03:37 UTC 2004


I'm building a small utility in Squeak that relies on the Rijndael (AES)
algorithm which relies heavily, in turn, on ThirtyTwoBitRegister.  I'm
finding that my app runs about 80x slower than the equivalent app in C#.
I also find that 59% of that time is spent in two methods on
ThirtyTwoBitRegister.  Another 22% is spent bit-twiddling in the
Rijndael class itself.  See the MessageTally results below for more
detail.

Is there any reason for me not to push basically all of
ThirtyTwoBitRegister's operations down into primitives, either in the VM
or plugins?

For that matter, would we be better off with all of the crypto stuff in
primitives?  Bit twiddling is one of Smalltalk's weaknessess (assuming
I'm willing to admit it has any ;-) and calling, say, functions in OpenSSL
might strengthen up a bit of an Achilles heel, especially as more and
more basic functionality relies on cryptography.  Thoughts?

-----

 - 90325 tallies, 90409 msec.

**Tree**
99.8% {90228ms} MyClass>>myMethod
  99.4% {89867ms} MyClass>>decryptCiphertext:offset:count:key:iv:
    94.1% {85075ms} CBC(BlockCipherMode)>>decrypt:
      |92.3% {83448ms} CBC>>decryptBlock:
      |  90.2% {81549ms} Rijndael>>decryptBlock:
      |    |83.9% {75853ms} Rijndael>>decryptState:
      |    |  |74.7% {67536ms} Rijndael>>eqRound:
      |    |  |  |33.3% {30106ms} ThirtyTwoBitRegister>>bitXor:
      |    |  |  |21.9% {19800ms} primitives
      |    |  |  |19.5% {17630ms} ThirtyTwoBitRegister>>byteAt:
      |    |  |6.7% {6057ms} Rijndael>>eqFinalRound:
      |    |  |  2.3% {2079ms} ThirtyTwoBitRegister>>byteAt:
      |    |4.1% {3707ms} Rijndael>>stateFromBytes:
      |    |  |4.1% {3707ms} Rijndael>>stateFromBytes:columns:
      |    |2.1% {1899ms} Rijndael>>storeState:into:
      |  2.1% {1899ms} primitives
    5.2% {4701ms} CBC(BlockCipherMode)>>key:
      5.2% {4701ms} Rijndael>>key:
        2.7% {2441ms} Rijndael>>eqExpandKey
          |2.3% {2079ms} Rijndael>>invMixColumn:
        2.4% {2170ms} Rijndael>>expandKey:

**Leaves**
36.7% {33180ms} ThirtyTwoBitRegister>>bitXor:
22.7% {20523ms} ThirtyTwoBitRegister>>byteAt:
21.9% {19800ms} Rijndael>>eqRound:
2.1% {1899ms} CBC>>decryptBlock:

**Memory**
	old		-5,155,876 bytes
	young		+4,200,368 bytes
	used		-955,508 bytes
	free		+802,840 bytes

**GCs**
	full		1 totalling 183ms (0.0% uptime), avg 183.0ms
	incr		5269 totalling 3,587ms (4.0% uptime), avg 1.0ms
	tenures		0
	root table	0 overflows
-- 
Jason Dufair - jase at dufair.org
http://www.dufair.org/
"Better to remain silent and be thought a fool,
than to speak and remove all doubt."
-- Abraham Lincoln




More information about the Squeak-dev mailing list