Skip to content

Defer loading OSQP for faster startup time - #162

Draft
hakkelt wants to merge 1 commit into
JuliaFirstOrder:masterfrom
hakkelt:defer-osqp-loading
Draft

Defer loading OSQP for faster startup time#162
hakkelt wants to merge 1 commit into
JuliaFirstOrder:masterfrom
hakkelt:defer-osqp-loading

Conversation

@hakkelt

@hakkelt hakkelt commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Defers loading of OSQP in indPolyhedralOSQP.jl so that importing ProximalOperators doesn't pay the OSQP startup cost unless it's actually needed.

Test plan

  • CI passes

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Results (Julia v1)

Time benchmarks
master 1f63da3... master / 1f63da3...
IndBallL1/Float32 4.57 ± 3.5 μs 3.26 ± 2.1 μs 1.4 ± 1.4
IndBallL1/Float64 4.63 ± 3.1 μs 3.82 ± 2 μs 1.21 ± 1
IndBox/Float32 7.71 ± 0.43 μs 7.72 ± 0.44 μs 0.998 ± 0.079
IndBox/Float64 7.73 ± 1.7 μs 7.71 ± 0.48 μs 1 ± 0.23
IndExpPrimal/Float32 0.127 ± 0.014 ms 0.123 ± 0.0091 ms 1.04 ± 0.14
IndExpPrimal/Float64 0.126 ± 0.016 ms 0.124 ± 0.012 ms 1.01 ± 0.16
IndNonnegative/Float32 3.6 ± 2.4 μs 2.6 ± 1.9 μs 1.39 ± 1.4
IndNonnegative/Float64 3.41 ± 3.7 μs 3.39 ± 2.4 μs 1.01 ± 1.3
IndPSD/("ComplexF64", 10) 12.9 ± 0.76 μs 13 ± 1.2 μs 0.993 ± 0.11
IndPSD/("ComplexF64", 20) 0.0544 ± 0.0063 ms 0.0482 ± 0.0011 ms 1.13 ± 0.13
IndPSD/("ComplexF64", 50) 0.379 ± 0.034 ms 0.37 ± 0.013 ms 1.02 ± 0.099
IndPSD/("Float64", 10) 10.5 ± 0.5 μs 10.5 ± 0.4 μs 1 ± 0.061
IndPSD/("Float64", 20) 0.0334 ± 0.0024 ms 0.0333 ± 0.001 ms 1 ± 0.079
IndPSD/("Float64", 50) 0.234 ± 0.012 ms 0.23 ± 0.0098 ms 1.02 ± 0.069
IndSimplex/Float32 17.7 ± 1.5 μs 17.6 ± 1.3 μs 1.01 ± 0.11
IndSimplex/Float64 19.4 ± 3.8 μs 17.9 ± 2.4 μs 1.08 ± 0.26
LeastSquares/("ComplexF64", "(11, 5)", 0, 0) 0.894 ± 0.15 μs 0.837 ± 0.13 μs 1.07 ± 0.24
LeastSquares/("ComplexF64", "(11, 5)", 0, 1) 0.993 ± 0.11 μs 1.01 ± 0.14 μs 0.981 ± 0.18
LeastSquares/("ComplexF64", "(11, 5)", 1, 0) 6.54 ± 0.99 μs 6.28 ± 0.37 μs 1.04 ± 0.17
LeastSquares/("ComplexF64", "(11, 5)", 1, 1) 1.01 ± 0.15 μs 0.927 ± 0.061 μs 1.09 ± 0.18
LeastSquares/("ComplexF64", "(5, 11)", 0, 0) 0.967 ± 0.081 μs 0.966 ± 0.13 μs 1 ± 0.16
LeastSquares/("ComplexF64", "(5, 11)", 0, 1) 1.11 ± 0.16 μs 1.12 ± 0.15 μs 0.994 ± 0.19
LeastSquares/("ComplexF64", "(5, 11)", 1, 0) 6.35 ± 0.47 μs 6.38 ± 0.51 μs 0.996 ± 0.11
LeastSquares/("ComplexF64", "(5, 11)", 1, 1) 1.12 ± 0.13 μs 1.1 ± 0.16 μs 1.02 ± 0.19
LeastSquares/("Float64", "(11, 5)", 0, 0) 0.687 ± 0.055 μs 0.673 ± 0.042 μs 1.02 ± 0.1
LeastSquares/("Float64", "(11, 5)", 0, 1) 0.862 ± 0.079 μs 0.882 ± 0.061 μs 0.977 ± 0.11
LeastSquares/("Float64", "(11, 5)", 1, 0) 5.98 ± 0.22 μs 6.04 ± 0.18 μs 0.99 ± 0.047
LeastSquares/("Float64", "(11, 5)", 1, 1) 0.819 ± 0.13 μs 0.826 ± 0.12 μs 0.992 ± 0.22
LeastSquares/("Float64", "(5, 11)", 0, 0) 0.797 ± 0.13 μs 0.785 ± 0.11 μs 1.02 ± 0.22
LeastSquares/("Float64", "(5, 11)", 0, 1) 1.06 ± 0.073 μs 0.921 ± 0.067 μs 1.15 ± 0.12
LeastSquares/("Float64", "(5, 11)", 1, 0) 6.08 ± 0.2 μs 6.13 ± 0.21 μs 0.99 ± 0.048
LeastSquares/("Float64", "(5, 11)", 1, 1) 0.94 ± 0.094 μs 0.864 ± 0.052 μs 1.09 ± 0.13
NormL2/Float32 4.73 ± 1.8 μs 5.09 ± 1.3 μs 0.928 ± 0.43
NormL2/Float64 6.36 ± 2.7 μs 6.16 ± 2.4 μs 1.03 ± 0.6
time_to_load 0.865 ± 0.0043 s 0.2 ± 0.0014 s 4.33 ± 0.038
Memory benchmarks
master 1f63da3... master / 1f63da3...
IndBallL1/Float32 10 allocs: 10.4 kB 10 allocs: 10.4 kB 1
IndBallL1/Float64 10 allocs: 20.5 kB 10 allocs: 20.5 kB 1
IndBox/Float32 1 allocs: 16 B 1 allocs: 16 B 1
IndBox/Float64 1 allocs: 16 B 1 allocs: 16 B 1
IndExpPrimal/Float32 11 k allocs: 0.179 MB 11 k allocs: 0.179 MB 1
IndExpPrimal/Float64 11 k allocs: 0.179 MB 11 k allocs: 0.179 MB 1
IndNonnegative/Float32 1 allocs: 16 B 1 allocs: 16 B 1
IndNonnegative/Float64 1 allocs: 16 B 1 allocs: 16 B 1
IndPSD/("ComplexF64", 10) 19 allocs: 11.9 kB 19 allocs: 11.9 kB 1
IndPSD/("ComplexF64", 20) 22 allocs: 29.2 kB 22 allocs: 29.2 kB 1
IndPSD/("ComplexF64", 50) 23 allocs: 0.116 MB 23 allocs: 0.116 MB 1
IndPSD/("Float64", 10) 16 allocs: 5.88 kB 16 allocs: 5.88 kB 1
IndPSD/("Float64", 20) 18 allocs: 14 kB 18 allocs: 14 kB 1
IndPSD/("Float64", 50) 19 allocs: 0.0564 MB 19 allocs: 0.0564 MB 1
IndSimplex/Float32 24 allocs: 0.0344 MB 24 allocs: 0.0344 MB 1
IndSimplex/Float64 26 allocs: 0.0685 MB 26 allocs: 0.0685 MB 1
LeastSquares/("ComplexF64", "(11, 5)", 0, 0) 7 allocs: 1.05 kB 7 allocs: 1.05 kB 1
LeastSquares/("ComplexF64", "(11, 5)", 0, 1) 17 allocs: 1.14 kB 17 allocs: 1.14 kB 1
LeastSquares/("ComplexF64", "(11, 5)", 1, 0) 0.059 k allocs: 4.6 kB 0.059 k allocs: 4.6 kB 1
LeastSquares/("ComplexF64", "(11, 5)", 1, 1) 17 allocs: 1.17 kB 17 allocs: 1.17 kB 1
LeastSquares/("ComplexF64", "(5, 11)", 0, 0) 7 allocs: 1.05 kB 7 allocs: 1.05 kB 1
LeastSquares/("ComplexF64", "(5, 11)", 0, 1) 17 allocs: 1.14 kB 17 allocs: 1.14 kB 1
LeastSquares/("ComplexF64", "(5, 11)", 1, 0) 0.059 k allocs: 4.6 kB 0.059 k allocs: 4.6 kB 1
LeastSquares/("ComplexF64", "(5, 11)", 1, 1) 17 allocs: 1.17 kB 17 allocs: 1.17 kB 1
LeastSquares/("Float64", "(11, 5)", 0, 0) 7 allocs: 0.609 kB 7 allocs: 0.609 kB 1
LeastSquares/("Float64", "(11, 5)", 0, 1) 17 allocs: 0.984 kB 17 allocs: 0.984 kB 1
LeastSquares/("Float64", "(11, 5)", 1, 0) 0.059 k allocs: 3.96 kB 0.059 k allocs: 3.96 kB 1
LeastSquares/("Float64", "(11, 5)", 1, 1) 17 allocs: 1.02 kB 17 allocs: 1.02 kB 1
LeastSquares/("Float64", "(5, 11)", 0, 0) 7 allocs: 0.609 kB 7 allocs: 0.609 kB 1
LeastSquares/("Float64", "(5, 11)", 0, 1) 17 allocs: 0.984 kB 17 allocs: 0.984 kB 1
LeastSquares/("Float64", "(5, 11)", 1, 0) 0.059 k allocs: 3.96 kB 0.059 k allocs: 3.96 kB 1
LeastSquares/("Float64", "(5, 11)", 1, 1) 17 allocs: 1.02 kB 17 allocs: 1.02 kB 1
NormL2/Float32 1 allocs: 16 B 1 allocs: 16 B 1
NormL2/Float64 1 allocs: 16 B 1 allocs: 16 B 1
time_to_load 0.149 k allocs: 11.2 kB 0.149 k allocs: 11.2 kB 1

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.95%. Comparing base (ccfc1c0) to head (1f63da3).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #162      +/-   ##
==========================================
- Coverage   93.79%   89.95%   -3.85%     
==========================================
  Files          80       79       -1     
  Lines        2596     2498      -98     
==========================================
- Hits         2435     2247     -188     
- Misses        161      251      +90     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant