Skip to content

Conversation

@gdalle
Copy link
Owner

@gdalle gdalle commented Mar 31, 2025

  • Store buckets in a contiguous vector with specified limits instead of a vector of vectors

@gdalle
Copy link
Owner Author

gdalle commented Mar 31, 2025

Benchmark full coloring

using SparseArrays, SparseMatrixColorings
using Chairmarks, StableRNGs

for n in (1000, 3000), p in (0.0003, 0.001, 0.003, 0.01)
    As = [sprand(StableRNG(i), Bool, n, n, p) for i in 1:10]
    problem = ColoringProblem()
    algo = GreedyColoringAlgorithm(DynamicLargestFirst())
    bench = @b fast_coloring.($As, $(Ref(problem)), $(Ref(algo))) seconds = 3
    @info "Benchmark: n=$n, p=$p"
    display(bench)
end

This branch:

[ Info: Benchmark: n=1000, p=0.0003
393.125 μs (362 allocs: 588.125 KiB)
[ Info: Benchmark: n=1000, p=0.001
656.292 μs (362 allocs: 645.938 KiB)
[ Info: Benchmark: n=1000, p=0.003
3.128 ms (362 allocs: 808.422 KiB)
[ Info: Benchmark: n=1000, p=0.01
19.676 ms (362 allocs: 1.362 MiB)
[ Info: Benchmark: n=3000, p=0.0003
2.776 ms (362 allocs: 1.834 MiB)
[ Info: Benchmark: n=3000, p=0.001
11.834 ms (362 allocs: 2.321 MiB)
[ Info: Benchmark: n=3000, p=0.003
55.021 ms (362 allocs: 3.726 MiB)
[ Info: Benchmark: n=3000, p=0.01
435.350 ms (392 allocs: 8.782 MiB)

Main branch:

[ Info: Benchmark: n=1000, p=0.0003
622.584 μs (583 allocs: 968.344 KiB)
[ Info: Benchmark: n=1000, p=0.001
1.244 ms (777 allocs: 996.750 KiB)
[ Info: Benchmark: n=1000, p=0.003
4.543 ms (1526 allocs: 1.380 MiB)
[ Info: Benchmark: n=1000, p=0.01
31.623 ms (5934 allocs: 2.639 MiB)
[ Info: Benchmark: n=3000, p=0.0003
4.389 ms (909 allocs: 2.717 MiB)
[ Info: Benchmark: n=3000, p=0.001
16.675 ms (1939 allocs: 3.789 MiB)
[ Info: Benchmark: n=3000, p=0.003
86.568 ms (6665 allocs: 6.467 MiB)
[ Info: Benchmark: n=3000, p=0.01
741.368 ms (34668 allocs: 14.959 MiB)

Benchmark just ordering

using SparseArrays, SparseMatrixColorings
using Chairmarks, StableRNGs

for n in (1000, 3000), p in (0.0003, 0.001, 0.003, 0.01)
    As = [sprand(StableRNG(i), Bool, n, n, p) for i in 1:10]
    gs = SparseMatrixColorings.BipartiteGraph.(As)
    order = DynamicLargestFirst()
    bench = @b SparseMatrixColorings.vertices.($gs, $(Ref(Val(2))), $(Ref(order))) seconds =
        3
    @info "Benchmark: n=$n, p=$p"
    display(bench)
end

This branch:

[ Info: Benchmark: n=1000, p=0.0003
321.125 μs (242 allocs: 324.875 KiB)
[ Info: Benchmark: n=1000, p=0.001
491.416 μs (242 allocs: 326.562 KiB)
[ Info: Benchmark: n=1000, p=0.003
2.114 ms (242 allocs: 332.422 KiB)
[ Info: Benchmark: n=1000, p=0.01
14.323 ms (242 allocs: 372.922 KiB)
[ Info: Benchmark: n=3000, p=0.0003
2.185 ms (242 allocs: 956.203 KiB)
[ Info: Benchmark: n=3000, p=0.001
8.269 ms (242 allocs: 963.234 KiB)
[ Info: Benchmark: n=3000, p=0.003
39.502 ms (242 allocs: 1001.156 KiB)
[ Info: Benchmark: n=3000, p=0.01
327.865 ms (272 allocs: 1.218 MiB)

Main branch:

[ Info: Benchmark: n=1000, p=0.0003
559.833 μs (463 allocs: 705.094 KiB)
[ Info: Benchmark: n=1000, p=0.001
1.090 ms (657 allocs: 677.375 KiB)
[ Info: Benchmark: n=1000, p=0.003
3.524 ms (1406 allocs: 936.641 KiB)
[ Info: Benchmark: n=1000, p=0.01
26.086 ms (5814 allocs: 1.640 MiB)
[ Info: Benchmark: n=3000, p=0.0003
3.841 ms (789 allocs: 1.817 MiB)
[ Info: Benchmark: n=3000, p=0.001
12.936 ms (1819 allocs: 2.409 MiB)
[ Info: Benchmark: n=3000, p=0.003
70.679 ms (6545 allocs: 3.718 MiB)
[ Info: Benchmark: n=3000, p=0.01
635.092 ms (34548 allocs: 7.395 MiB)

@codecov
Copy link

codecov bot commented Mar 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (5c9b8c7) to head (997ca35).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #220   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           15        15           
  Lines         1642      1680   +38     
=========================================
+ Hits          1642      1680   +38     

☔ View full report in Codecov by Sentry.
📢 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.

@gdalle gdalle marked this pull request as ready for review March 31, 2025 22:54
@amontoison
Copy link
Collaborator

All tests passed and you have good results in the benchmarks.
I merge the PR 👍

@amontoison amontoison merged commit 9fbbce4 into main Apr 1, 2025
6 checks passed
@amontoison amontoison deleted the gd/efficientorder branch April 1, 2025 00:00
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.

2 participants