Previously we used float64 log to calculate a tick from price. There is no strong guarantee that float64 math will perform the same on all issues and poses a small risk of being consensus-breaking. To fix this we switch to using a pre-calculated array of prices which we binary search to find the correct tick for a given price. This is also slightly more efficient and gives us the option to stop doing all price calculations in the future.
The price data structure is loaded into memory from a .gob file at startup. The full data structure is calculated to use about 8mb of space, so should have a negligible impact on overall performance
Previously we used float64 log to calculate a tick from price. There is no strong guarantee that float64 math will perform the same on all issues and poses a small risk of being consensus-breaking. To fix this we switch to using a pre-calculated array of prices which we binary search to find the correct tick for a given price. This is also slightly more efficient and gives us the option to stop doing all price calculations in the future.
Benchmarks: BenchmarkCalcTickIndexFromPriceV2 301816 5249 ns/op BenchmarkCalcTickIndexFromPrice 206276 6662 ns/op
The price data structure is loaded into memory from a .gob file at startup. The full data structure is calculated to use about 8mb of space, so should have a negligible impact on overall performance