ssz icon indicating copy to clipboard operation
ssz copied to clipboard

Improve intToBytes, bytesToInt for number

Open twoeths opened this issue 4 years ago • 4 comments
trafficstars

Is your feature request related to a problem? Please describe. Right now these utils convert to BigInt unnecessarily and we know that we have performance issue with using BigInt

Describe the solution you'd like Reimplement these functions without going through bigint-buffer

twoeths avatar Mar 02 '21 10:03 twoeths

@tuyennhv According to a CPU profile are the intToBytes, bytesToInt functions part of a critically hot path worth optimizing?

dapplion avatar Mar 21 '21 13:03 dapplion

@tuyennhv According to a CPU profile are the intToBytes, bytesToInt functions part of a critically hot path worth optimizing?

no this is not critical, these functions just use BigInt unnecessarily so we want to improve them to avoid some memory allocation whenever possible.

twoeths avatar Mar 22 '21 03:03 twoeths

https://github.com/ChainSafe/lodestar/pull/2213

Can this be closed since the above PR tried to do this but the trade offs were not good enough? Or are you guys still looking for a better implementation?

filipesmedeiros avatar Sep 19 '21 23:09 filipesmedeiros

@filipesmedeiros We are still looking for a better implementation! However this should be implemented in ssz rather than here. Will move the issue, feel free to propose better strategies, in ssz we have already benchmarking infrastructure setup

dapplion avatar Sep 20 '21 13:09 dapplion