big-math icon indicating copy to clipboard operation
big-math copied to clipboard

Performance issue in BigDecimalMath.pow()

Open ekuleshov opened this issue 1 year ago • 1 comments

The BigDecimalMath.pow() method is relying on Exception handling to recover from some corner cases. In my profiling the BigDecimal.longValueExcact() can throw ArithmeticException("Rounding necessary") which takes a large chunk of the BigDecimalMath.pow() execution time. The time is X axis on the flame graph below - roughly 50%?

image

The issue seem to be with try/catch code below and I wonder if the exception could be mitigated with some conditions inside try/catch to avoid some common cases of the ArithmeticException?

image

ekuleshov avatar Nov 24 '22 22:11 ekuleshov