roc230 / spymemcached

Automatically exported from code.google.com/p/spymemcached
0 stars 0 forks source link

Performance tweak when creating md5 digest #29

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Using:
memcached-2.0.2.jar
spy.jar vers. 2.4

In HashAlgorithm.computeMd5() the MessageDigest gets created for every
call. I guess this can reduce performance. Creating the digest in a static
way during initialization of the class and synchronizing on md5 during
reset(), update() and digest() might help to improve performance. 

Original issue reported on code.google.com by misch...@gmail.com on 13 May 2008 at 3:57

GoogleCodeExporter commented 9 years ago
This measures slower on my machine:

5 threads, 10 in pool, mode: NEW
Processing time:  71ms
15 threads, 10 in pool, mode: NEW
Processing time:  229ms
50 threads, 10 in pool, mode: NEW
Processing time:  776ms
5 threads, 10 in pool, mode: LOCKED
Processing time:  102ms
15 threads, 10 in pool, mode: LOCKED
Processing time:  331ms
50 threads, 10 in pool, mode: LOCKED
Processing time:  1166ms

Run the attached test to try it against yours.

Original comment by dsalli...@gmail.com on 14 May 2008 at 3:28

Attachments:

GoogleCodeExporter commented 9 years ago
BTW, if performance is a concern, you should really use a different hash.  md5 
was
designed to be of cryptographic quality, not for performance.

Original comment by dsalli...@gmail.com on 14 May 2008 at 3:30