--
You received this message because you are subscribed to the Google Groups "Bitcoin Hackers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to BitcoinHacker...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Bitcoin Hackers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to BitcoinHacker...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Bitcoin Hackers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to BitcoinHacker...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hey Brooks, glad you're back!A few weeks ago, I spent some time looking at the internals of bigi. I think the performance gains come from leveraging the fact that JavaScript can handle integers up to 53 bits (because of IEEE doubles). Since buffers are backed by a byte array, any arithmetic is using 8 bit numbers as opposed to the much larger 53 bits. This in turn will cause the processor to do more arithmetic operations for the same computation. At least that's the hypothesis that I can come up with.Overall, I think it makes sense to not transition bigi to buffers. It helps that bigi now has the methods "fromBuffer" and "toBuffer". But for the rest of libraries, where it makes sense, transition to buffers. Internally, some libraries like the crypto ones it will not make sense to convert to buffers because of the same reason stated above. However, I think it definitely makes sense to transition almost all object and method interfaces to use buffers.-JP
--
You received this message because you are subscribed to the Google Groups "Bitcoin Hackers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to BitcoinHacker...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sorry, I don't think that I expressed my thoughts as clearly as I wanted.Ok, so we know that `bigi` must be backed by something to store the data that represents a big integer. Currently, it's backed by a regular JS Array of integers whose max size is 53 bits (err, might be 52 in this case). The alternative, and sounds like what you may be proposing is to back `bigi` with a Buffer.I'm positing that backing `bigi` with a Buffer will be slower in both Node.js and the browser. This is because in both cases, Buffer is backed by an 8-bit byte array (https://github.com/joyent/node/blob/master/lib/buffer.js) and (https://github.com/feross/buffer/blob/master/index.js). Yes, you can use Buffer and access 32 bit integers, but as you can see in both cases, you're doing four sequential reads (negligible on speed), bit shifting (maybe not a huge impact), and math on 32 bit integers as opposed to just doing math on 53 bit integers. Now JITs may play a role, but I'm still betting that the Array of 53 bit numbers will outperform in every case.I could be wrong though, but after looking at it from this perspective, it seemed to me that my time would be better spent integrating Buffers elsewhere. That's all.Thoughts?