memfrob()
markos — Tue, 29/01/2008 - 17:54
Description
According to the man page, memfrob() encrypts the first n bytes of the memory area s by exclusive-ORing each character with the number 42. The effect can be reversed by using memfrob() on the encrypted memory area. Note that this function is not a proper encryption routine as the XOR constant is fixed, and is only suitable for hiding strings. It returns a pointer to the encrypted memory area.
memfrob() will probably be considered as a joke function rather than one with a serious use. However, it's a perfect example just how much performance can be improved when we're actually using the architecture to our benefit. The glibc implementation does per-byte processing which is totally awful for performance. However, in libfreevec we use modern SIMD units (AltiVec for PowerPC CPUs, and in the future SSE for x86 CPUs).
Each CPU in detail:
And for comparison here is the result of the same benchmark run on an Athlon X2 5000 (2.5Ghz), running 32-bit code:
Results/Comments
The AltiVec version completely trounces the scalar per-byte processing with up to 37x speed improvement in the case of the G5. However fast the Athlon is, it cannot reach the performance of the PowerPC CPUs when using Altivec, though a more fair comparison would be the Athlon using SSE/3DNow! code, which will happen soon.
- Login to post comments