-
-
Notifications
You must be signed in to change notification settings - Fork 789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adler32 optimization #28
Comments
5552 is limit for 32 bit int, calculated by someone clever :) . This constant exists in all implementations. I don't remember details. Also, i can advice you to dig adler32 in native zlib sources, it has 2 unrollings. Those are stripped here as "not making sense for JS" |
@puzrin 5552 actually comes from the same formula (you assume the worst case):
|
May be. There should be no noticeable difference, when this value > 1000 (benchmarked). I just quickly taken safe value and switched to another task. |
On node, it appears the performance benefit comes from the structure of the loop: Your loop involves two variables ( https://github.com/nodeca/pako/blob/master/lib/zlib/adler32.js#L19-L22 This can actually be done with one moving variable (calculate the intermediate goalpost and just increment the address): https://github.com/SheetJS/js-adler32/blob/master/adler32.js#L27-L31 |
May be, As i explainted in email, i have no special interest to participate in minor optimizations. If you wish - create a benchmark, that demonstrate that whole inflate/deflate can have noticeable benefits, and i'll be glad to accept pull request. I'm not out of programming. Just have to concentrate on another tasks, like refactoring js-yaml, mincer and developping main nodeca project. |
Closed - timed out, not significant. When improvments, confirmed with pako benchmarcs available - just create a new ticket. |
I've tested a few ways to optimize the 65521 mod operation. As evidenced by http://jsperf.com/mod-65521 replacing the mod with a bit-based approximation is significantly faster on safari, comparable in firefox and chrome, and about 10% faster in node 0.10.29.
Also:
How did you arrive at that logic? As per my calculation, the upper threshold can be boosted to 3850 without overflowing a 31-bit integer:
The text was updated successfully, but these errors were encountered: