mbutrovich opened a new issue, #12170:
URL: https://github.com/apache/arrow-rs/issues/12170

   ### Is your feature request related to a problem or challenge?
   
   Part of #11421.
   
   `multiply_fixed_point` rescales each `i256` product with 
[`divide_and_round`](https://github.com/apache/arrow-rs/blob/6b34163d51aa59f7cac2edcb74e8bd1ddc6b9120/arrow-arith/src/arithmetic.rs#L172-L186),
 which divides by the same power of ten for every row and rounds half away from 
zero. After #11526 it divides once per row. That division is `i256::div_rem`, 
which is Knuth's Algorithm D unless one of the fast paths from #11451 applies.
   
   ### Describe the solution you'd like
   
   Build an `i256` divisor once per call and use it in `divide_and_round`, with 
the half-up helper from {{02}}. This needs the `i256` divisor from {{01}}. When 
every product in a batch fits in `i128`, use the 128-bit variant, which is 4.2x 
faster than today for such products in Comet's equivalent kernel.
   
   The `decimal_division` benchmark from #11427 covers `multiply_fixed_point`. 
The PR reports the bot's before and after numbers for products that fit in 
`i128` and products that don't, so the cost of the magnitude scan on wide 
values is visible (4% to 8% in the prototype).
   
   `multiply_fixed_point` currently returns wrong values or panics when the 
required scale is more than 76 below the product scale (#11605). This PR should 
keep that behavior as it is, or land after the fix.
   
   ### Describe alternatives you've considered
   
   None beyond the ones in #11421.
   
   ### Additional context
   
   Comet's kernel for the same operation, `div_round_half_up`, measured 266.5 
us per 8192-row batch today against 63.4 us with the per-batch 128-bit variant, 
and 398.1 against 147.1 us for 48-digit products with the 256-bit variant. The 
table is in {{01}}.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to