apache / arrow-rs

Official Rust implementation of Apache Arrow
https://arrow.apache.org/
Apache License 2.0
2.47k stars 735 forks source link

Faster i256 Division #4663

Closed tustvold closed 1 year ago

tustvold commented 1 year ago

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

i256 division is currently implemented using long division, this is simple but its time complexity is linear with respect to the number of digits in the output quotient. As a result it degrades poorly when dividing large numbers by smaller numbers.

Describe the solution you'd like

There are more sophisticated algorithms for multi-digit division, most famously Knuth Algorithm D.

Describe alternatives you've considered

Additional context

I have a draft implementation of this, that provides a non-trivial performance uplift

tustvold commented 1 year ago

label_issue.py automatically added labels {'arrow'} from #4672