Skip to main content

collect_overflowing

Function collect_overflowing 

Source
fn collect_overflowing<N>(
    iter: impl ExactSizeIterator<Item = (N, bool)>,
) -> Result<(Vec<N>, bool), ArrowError>
Expand description

Collects the values of iter, and whether any was flagged as overflowed.

This intentional inline(never) keeps overflow in a register. Inlined into its caller under thin LTO, LLVM keeps the flag in memory and loads and stores it on every row, which serializes the loop and keeps it from vectorizing. The loop writes into the Vec’s spare capacity itself, because whether LLVM inlines the loop inside collect depends on the closure and the target, and when it doesn’t, that loop reaches the flag through a pointer. The checked add cases of the arithmetic_kernels benchmark measure this.