neilconway opened a new pull request, #10974: URL: https://github.com/apache/arrow-rs/pull/10974
# Which issue does this PR close? - Closes #10961. # Rationale for this change We recently consolidated the decimal parsing code to use a single, more correct implementation (#10850); however, this resulted in regression performance somewhat. `parse_decimal` used a single loop to scan each digit of the input. Digits before and after the decimal point are treated very differently; profiling the code revealed that doing a data-dependent branch for each digit resulted in worse codegen. Instead, we can split the parsing logic to use two loops, in sequence: first look for digits that precede the decimal point, then those that follow. This avoids the data-dependent branch and seems to significantly improve codegen. On M4 Max, this improves the end-to-end CSV parsing benchmark by 5-15%, and the `parse_decimal` microbenchmark by 5-33%. # What changes are included in this PR? * Split decimal parsing logic into two sequential loops * Refactor digit accumulation logic to avoid duplication * Mark `fold_decimal_chunk` as `inline(always)` -- the refactor resulted in LLVM deciding not to inline this call inside the hot loop, which regressed performance significantly. # Are these changes tested? Yes, covered by existing tests. # Are there any user-facing changes? No. # Tool usage Explored optimization ideas and developed this optimization with Claude Code (Fable 5.1). I revised and understand the resulting code. -- 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]
