
Anatoly Yakovenko wrote:
I don't think the problem with performance of crypto has anything to do with unpacking ByteStrings. If I unpack the bytestrings first, then run the hash, and just time the hash algorithm, i still get 4 seconds with crypto where the C implementation gives me 0.02 seconds. Thats 200 times slower in haskell, to me it just seems like a bad implementation. You should be able to stay within an order of magnitude from C with haskell without resorting to weird compiler tricks.
Anatoly, the idea to unpack is the problem. You have to operate directly on the ByteString to get decent performance, for instance with a fold. Compare import Data.ByteString.Lazy as BS -- very slow checksum = foldl' xor 0 . BS.unpack -- blazingly fast checksum' = BS.foldl' xor 0 Regards, apfelmus