sjcl
sjcl copied to clipboard
Accelerate bitArray by use of Typed Arrays
Since Javascript Typed Arrays enjoy an increasing adoption by browser vendors perhaps this excellent library can be made even faster by using typed arrays for low level IO.
Possibly, yes. Last time I tried this, it was actually slower... but perhaps typed arrays have improved since?
On the other hand, I definitely do like the idea of an array that can be accessed both as a byte array and a word32 array.
This issue was brought up a while ago, and I'm sure the browser vendors have optimized this. I'm going to attempt to rework the code to use typed arrays. It should be a lot faster when trying to {de,en}crypt a large amount of binary data. Any tips for going through the code?
I would start by testing the AES code. If that's faster with typed arrays, the rest might be as well.
On Aug 8, 2012, at 12:14 AM, Marco Munizaga [email protected] wrote:
This issue was brought up a while ago, and I'm sure the browser vendors have optimized this. I'm going to attempt to rework the code to use typed arrays. It should be a lot faster when trying to {de,en}crypt a large amount of binary data. Any tips for going through the code?
— Reply to this email directly or view it on GitHub.
Typed arrays are much faster in every browser that supports them now. This issue should be a priority.
Created a pull request with a much faster implementation of ccm encryption/decryption https://github.com/bitwiseshiftleft/sjcl/pull/89
Mozilla dev here; we were looking at SJCL's performance and noticed that the bitArray idiom of storing the number of bits in the last element of the array is getting hit by significant slowdowns. With one element in the array being non-int32, the JIT can no longer say that loads from the array are always int32, so it slows down all accesses to the array.
Typed arrays are indeed very well optimized in many browsers today, and I encourage their use here, as they're likely to get good performance, and they seem like a good fit here.