Git Product home page Git Product logo

Comments (6)

puzrin avatar puzrin commented on August 20, 2024

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"

from pako.

SheetJSDev avatar SheetJSDev commented on August 20, 2024

5552 is limit for 32 bit int, calculated by someone clever :)

@puzrin 5552 actually comes from the same formula (you assume the worst case):

(* Run this in Mathematica *)
(* n is the maximum value for a term -- 255 for bytes *)
(* bits is the size of the containing value -- 31 for signed 32 bit ints, 32 for unsigned *)
G[n_, bits_] :=  Reduce[x*(x + 1)*n/2 + (x + 1)*(65521) < (2^bits - 1) && x > 0, x, Integers]
G[255, 32] (* x \[Element] Integers && 1 <= x <= 5552 *)

from pako.

puzrin avatar puzrin commented on August 20, 2024

May be. There should be no noticeable difference, when this value > 1000 (benchmarked). I just quickly taken safe value and switched to another task.

from pako.

SheetJSDev avatar SheetJSDev commented on August 20, 2024

On node, it appears the performance benefit comes from the structure of the loop:

Your loop involves two variables (n and pos), both moving in lockstep:

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

from pako.

puzrin avatar puzrin commented on August 20, 2024

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.

from pako.

puzrin avatar puzrin commented on August 20, 2024

Closed - timed out, not significant. When improvments, confirmed with pako benchmarcs available - just create a new ticket.

from pako.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.