by vanderZwan · 8y ago · 0 comments
So I heavily experimented with squeezing performance out of a JS-based trie-implementation for LZString[0]. Back then some early experimentation suggested that using TypedArrays was likely to be slower than using objects with numerical keys, and for non-degenerate input using a trie based on plain arrays and indexOf calls was the fastest[1]. However, it's been a while since I looked at those numbers (and I suspect that with uBlock's use case look-up performance matters more than insertion performance, which makes it very different from LZString's).
But it should be obvious that HNTrie's implementation[2] is something I'm very interested in ;).
[0] https://github.com/pieroxy/lz-string/pull/98
[1] https://github.com/pieroxy/lz-string/blob/ba8988028d78962eba...
[2] https://github.com/gorhill/uBlock/blob/2a91a685ce3d2dae5d3c2...
Incidentally, I did write a JS/WASM version of LZ4 block encoding[1] (also used in uBO). I do wonder if it could be of interest for the LZString project.
My understanding is that the output of LZ4 compression would need to be further processed to make it JS string-friendly (for localStorage purpose).
Maybe worth exploring if even with that extra step[2], the performance gain if any is worth it?
[1] https://github.com/gorhill/lz4-wasm
[2] Encode 7 bytes into 8 valid ASCII characters?