sjcl icon indicating copy to clipboard operation
sjcl copied to clipboard

Accelerate bitArray by use of Typed Arrays

Open oliverw opened this issue 14 years ago • 6 comments

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.

oliverw avatar Aug 26 '11 15:08 oliverw

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.

bitwiseshiftleft avatar Aug 26 '11 19:08 bitwiseshiftleft

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?

MarcoPolo avatar Aug 08 '12 07:08 MarcoPolo

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.

bitwiseshiftleft avatar Aug 08 '12 07:08 bitwiseshiftleft

Typed arrays are much faster in every browser that supports them now. This issue should be a priority.

eligrey avatar Jul 10 '13 00:07 eligrey

Created a pull request with a much faster implementation of ccm encryption/decryption https://github.com/bitwiseshiftleft/sjcl/pull/89

MarcoPolo avatar Aug 11 '13 19:08 MarcoPolo

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.

sunfishcode avatar Aug 22 '14 23:08 sunfishcode