ds4dm / Tulip.jl

Interior-point solver in pure Julia
Other
154 stars 20 forks source link

performance: fuse more vectorized operations #127

Closed nsajko closed 2 years ago

nsajko commented 2 years ago

https://docs.julialang.org/en/v1.8/manual/performance-tips/#More-dots:-Fuse-vectorized-operations

I ran a benchmark with Tulip.Optimizer{MultiFloats.Float64x8}(): there was no speed improvement with this benchmark, but the reduction in allocations was significant. This would translate to less GC time in a more complex application, I guess.

State on master (ae81ed857f96f1dbe279664f8b5504621880c61e):

BenchmarkTools.Trial: 16 samples with 1 evaluation.
 Range (min … max):  308.254 ms … 322.011 ms  ┊ GC (min … max): 0.00% … 2.00%
 Time  (median):     309.053 ms               ┊ GC (median):    0.00%
 Time  (mean ± σ):   312.932 ms ±   6.263 ms  ┊ GC (mean ± σ):  0.64% ± 0.95%

   ▁▄▄▁                                                       █
  ▆████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▆█ ▁
  308 ms           Histogram: frequency by time          322 ms <

 Memory estimate: 26.14 MiB, allocs estimate: 93251.

State after "performance: fuse more vectorized operations":

julia> @benchmark polynomial_passing_through_intervals!(lp, 3, xs, ys) setup=(Random.seed!(876234567876); lp = Tulip.Optimizer{Float64x8}(); xs = map(Rational{BigInt}, 0:(2^7 - 1)); ys = map(t -> map(Float64x8, t), f(sqrt, 2^7)))
BenchmarkTools.Trial: 16 samples with 1 evaluation.
 Range (min … max):  309.502 ms … 329.415 ms  ┊ GC (min … max): 0.00% … 2.20%
 Time  (median):     310.327 ms               ┊ GC (median):    0.00%
 Time  (mean ± σ):   314.849 ms ±   8.429 ms  ┊ GC (mean ± σ):  0.60% ± 1.02%

  █▄█                                                       ▁ ▁
  ███▁▁▆▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█▁█ ▁
  310 ms           Histogram: frequency by time          329 ms <

 Memory estimate: 21.71 MiB, allocs estimate: 92692.
codecov-commenter commented 2 years ago

Codecov Report

Merging #127 (626e67b) into master (ae81ed8) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #127   +/-   ##
=======================================
  Coverage   89.01%   89.02%           
=======================================
  Files          43       43           
  Lines        2759     2751    -8     
=======================================
- Hits         2456     2449    -7     
+ Misses        303      302    -1     
Impacted Files Coverage Δ
src/IPM/HSD/HSD.jl 87.30% <100.00%> (-0.20%) :arrow_down:
src/IPM/HSD/step.jl 94.73% <100.00%> (-0.07%) :arrow_down:
src/IPM/MPC/MPC.jl 87.33% <100.00%> (-0.17%) :arrow_down:
src/IPM/MPC/step.jl 95.33% <100.00%> (-0.07%) :arrow_down:
src/IPM/ipmdata.jl 91.78% <100.00%> (ø)
src/Presolve/row_singleton.jl 92.45% <0.00%> (+1.88%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

mtanneau commented 2 years ago

Thanks @nsajko !