You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current version of packDecimal shows a 3x slowdown compared to the version in the benchmark. This is due to the n0 > fromIntegral (maxBound :: Word64) guard in numDecimalDigits. This must be corrected. a 1.2x slowdown may be acceptable, but 3x is not.
The text was updated successfully, but these errors were encountered:
On further investigation, the slowdown is almost surely due to taking the slow-path when we shouldn't, rather than due to the guard itself introducing slowness; that is, the guard is returning true when it shouldn't. The fromIntegral function has modular-arithmetic semantics for all the built-in Int/Word types, and this is causing things to go haywire.
For example, when a ~ Int64 we have that fromIntegral(maxBound::Word64) == -1, which in turn means n0 > -1 will always return true (since we've already filtered out the negative numbers), thus we'll always take the slow-path— even though in truth every single non-negative 'Int64' can be perfectly well embedded into Word64, so there's no actual risk of the fast-path breaking.
The easiest fix is to change the guard to toInteger n0 > toInteger (maxBound::Word64). If the guard itself seems to be introducing the slowness, then we can do some bit-bashing to speed that up.
The current version of packDecimal shows a 3x slowdown compared to the version in the benchmark. This is due to the
n0 > fromIntegral (maxBound :: Word64)
guard innumDecimalDigits
. This must be corrected. a 1.2x slowdown may be acceptable, but 3x is not.The text was updated successfully, but these errors were encountered: