JuliaFolds / Transducers.jl

Efficient transducers for Julia
https://juliafolds.github.io/Transducers.jl/dev/
MIT License
432 stars 24 forks source link

Specialize foldl for cartesian style arrays #407

Closed tkf closed 4 years ago

tkf commented 4 years ago

Commit Message

Specialize foldl for cartesian style arrays (#407)

This patch implements a specialization of foldl on arrays with IndexCartesian index style. This gives us more than 2x speedup (see sum_transpose benchmark).

The implementation mostly just redirects the call to foldl of CartesianIndices. Most of the code is for compatibility with Julia < 1.5. This PR also fixes a bug in foldl for multi-dimensional Broadcasted (probably introduced by #403).

codecov[bot] commented 4 years ago

Codecov Report

Merging #407 into master will increase coverage by 0.06%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #407      +/-   ##
==========================================
+ Coverage   90.82%   90.89%   +0.06%     
==========================================
  Files          25       25              
  Lines        1581     1592      +11     
==========================================
+ Hits         1436     1447      +11     
  Misses        145      145              
Impacted Files Coverage Δ
src/basics.jl 92.10% <100.00%> (+1.48%) :arrow_up:
src/processes.jl 93.03% <100.00%> (+0.17%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b8efeed...202df0a. Read the comment docs.

tkf commented 4 years ago

https://github.com/JuliaFolds/Transducers-data/blob/benchmark-results/2020/08/09/100019/result.md

ID time ratio memory ratio
["sum_transpose", "30", "noinit", "xf"] 0.43 (5%) :white_check_mark: Inf (1%) :x:
["sum_transpose", "30", "withinit", "xf"] 0.41 (5%) :white_check_mark: Inf (1%) :x: