Skip to content

Parallelize canonization#106

Merged
jdaymude merged 10 commits intomainfrom
parallel-canon
Aug 4, 2025
Merged

Parallelize canonization#106
jdaymude merged 10 commits intomainfrom
parallel-canon

Conversation

@AgentElement
Copy link
Collaborator

@AgentElement AgentElement commented Jul 30, 2025

  • canonize::is_tree now uses bitsets instead of hashsets when counting the subgraph's nodes.
  • Previously, when a tree has multiple children, their canonical strings were combined as something equivalent to (child1)(child2)...(childn). The internal delimiter pairs )( are replaced by a distinct third delimiter akin to a comma, yielding shorter labels: (child1,child2,...,childn). This change was good in theory, but was slower in practice and abandoned.
  • When using ParallelMode::Always or ParallelMode:DepthOne, the matches function now bins subgraphs into isomorphism classes in parallel (using a parallel-aware dashmap::DashMap).

@jdaymude
Copy link
Contributor

jdaymude commented Aug 4, 2025

Benchmarking Results for 60cfc9c (this) vs. 7539cef (main)

The results of cargo bench --bench benchmark -- --baseline 7539cef --load-baseline 60cfc9c:

bench_enumerate/gdb13_1201/extend                        
                        time:   [26.430 ms 26.437 ms 26.444 ms]
                        change: [-0.2968% -0.2563% -0.2165%] (p = 0.00 < 0.05)
                        Change within noise threshold.
bench_enumerate/gdb13_1201/grow-erode                        
                        time:   [12.281 ms 12.284 ms 12.286 ms]
                        change: [+0.5535% +0.5853% +0.6124%] (p = 0.00 < 0.05)
                        Change within noise threshold.
bench_enumerate/gdb17_200/extend                        
                        time:   [372.26 ms 372.34 ms 372.42 ms]
                        change: [+1.1204% +1.1493% +1.1788%] (p = 0.00 < 0.05)
                        Performance has regressed.
bench_enumerate/gdb17_200/grow-erode                        
                        time:   [113.34 ms 113.38 ms 113.42 ms]
                        change: [+0.4600% +0.5015% +0.5467%] (p = 0.00 < 0.05)
                        Change within noise threshold.
bench_enumerate/checks/extend                        
                        time:   [146.57 ms 146.67 ms 146.79 ms]
                        change: [+0.5118% +0.6872% +0.8401%] (p = 0.00 < 0.05)
                        Change within noise threshold.
bench_enumerate/checks/grow-erode                        
                        time:   [31.614 ms 31.624 ms 31.635 ms]
                        change: [-0.4693% -0.4279% -0.3851%] (p = 0.00 < 0.05)
                        Change within noise threshold.
bench_enumerate/coconut_55/extend                        
                        time:   [1.2344 s 1.2347 s 1.2350 s]
                        change: [-0.9497% -0.3562% +0.1354%] (p = 0.24 > 0.05)
                        No change in performance detected.
bench_enumerate/coconut_55/grow-erode                        
                        time:   [272.49 ms 272.56 ms 272.63 ms]
                        change: [+0.9121% +0.9549% +0.9956%] (p = 0.00 < 0.05)
                        Change within noise threshold.

bench_canonize/gdb13_1201/nauty                        
                        time:   [106.23 ms 106.28 ms 106.34 ms]
                        change: [+0.7569% +0.8276% +0.9035%] (p = 0.00 < 0.05)
                        Change within noise threshold.
bench_canonize/gdb13_1201/tree-nauty                        
                        time:   [55.936 ms 55.962 ms 55.987 ms]
                        change: [-9.8061% -9.7010% -9.5862%] (p = 0.00 < 0.05)
                        Performance has improved.
bench_canonize/gdb17_200/nauty                        
                        time:   [2.6299 s 2.6315 s 2.6332 s]
                        change: [-0.2784% -0.2072% -0.1337%] (p = 0.00 < 0.05)
                        Change within noise threshold.
bench_canonize/gdb17_200/tree-nauty                        
                        time:   [1.1628 s 1.1635 s 1.1642 s]
                        change: [-4.9351% -4.8376% -4.7398%] (p = 0.00 < 0.05)
                        Performance has improved.
bench_canonize/checks/nauty                        
                        time:   [1.2371 s 1.2403 s 1.2431 s]
                        change: [+1.1575% +1.4465% +1.6836%] (p = 0.00 < 0.05)
                        Performance has regressed.
bench_canonize/checks/tree-nauty                        
                        time:   [444.06 ms 444.90 ms 445.73 ms]
                        change: [-1.4436% -1.1516% -0.8590%] (p = 0.00 < 0.05)
                        Change within noise threshold.
bench_canonize/coconut_55/nauty                        
                        time:   [11.654 s 11.749 s 11.849 s]
                        change: [-3.1066% -2.2170% -1.4172%] (p = 0.00 < 0.05)
                        Performance has improved.
bench_canonize/coconut_55/tree-nauty                        
                        time:   [4.3415 s 4.3484 s 4.3550 s]
                        change: [+2.3180% +2.5432% +2.7653%] (p = 0.00 < 0.05)
                        Performance has regressed.

bench_bounds/gdb13_1201/no-bounds                        
                        time:   [63.187 ms 63.505 ms 63.818 ms]
                        change: [+5.7547% +6.4152% +7.0704%] (p = 0.00 < 0.05)
                        Performance has regressed.
bench_bounds/gdb13_1201/log                        
                        time:   [58.366 ms 58.644 ms 58.924 ms]
                        change: [+3.9892% +4.6793% +5.4122%] (p = 0.00 < 0.05)
                        Performance has regressed.
bench_bounds/gdb13_1201/int                        
                        time:   [48.720 ms 48.981 ms 49.244 ms]
                        change: [+5.8524% +6.5710% +7.2963%] (p = 0.00 < 0.05)
                        Performance has regressed.
bench_bounds/gdb13_1201/int-vec                        
                        time:   [46.788 ms 47.071 ms 47.361 ms]
                        change: [+4.2874% +5.2914% +6.3024%] (p = 0.00 < 0.05)
                        Performance has regressed.
bench_bounds/gdb17_200/no-bounds                        
                        time:   [1.2363 s 1.2478 s 1.2595 s]
                        change: [-3.5566% -2.0265% -0.4742%] (p = 0.02 < 0.05)
                        Change within noise threshold.
bench_bounds/gdb17_200/log                        
                        time:   [783.92 ms 789.39 ms 795.00 ms]
                        change: [-3.0747% -2.1475% -1.3117%] (p = 0.00 < 0.05)
                        Performance has improved.
bench_bounds/gdb17_200/int                        
                        time:   [174.07 ms 174.72 ms 175.43 ms]
                        change: [-12.428% -11.920% -11.387%] (p = 0.00 < 0.05)
                        Performance has improved.
bench_bounds/gdb17_200/int-vec                        
                        time:   [76.214 ms 76.555 ms 76.877 ms]
                        change: [-28.631% -27.947% -27.254%] (p = 0.00 < 0.05)
                        Performance has improved.
bench_bounds/checks/no-bounds                        
                        time:   [1.1020 s 1.1356 s 1.1721 s]
                        change: [-4.9606% -0.9356% +2.7356%] (p = 0.63 > 0.05)
                        No change in performance detected.
bench_bounds/checks/log time:   [475.20 ms 488.11 ms 502.81 ms]
                        change: [-3.1365% +0.4069% +4.2252%] (p = 0.84 > 0.05)
                        No change in performance detected.
bench_bounds/checks/int time:   [90.709 ms 92.265 ms 93.862 ms]
                        change: [-5.6455% -2.9099% +0.0618%] (p = 0.07 > 0.05)
                        No change in performance detected.
bench_bounds/checks/int-vec                        
                        time:   [15.968 ms 16.115 ms 16.279 ms]
                        change: [-3.2919% -1.4946% +0.1872%] (p = 0.12 > 0.05)
                        No change in performance detected.
bench_bounds/coconut_55/no-bounds                        
                        time:   [16.867 s 17.189 s 17.544 s]
                        change: [-4.9439% -2.4353% +0.2764%] (p = 0.09 > 0.05)
                        No change in performance detected.
bench_bounds/coconut_55/log                        
                        time:   [13.861 s 14.111 s 14.379 s]
                        change: [-2.2578% -0.3164% +1.7106%] (p = 0.78 > 0.05)
                        No change in performance detected.
bench_bounds/coconut_55/int                        
                        time:   [784.03 ms 796.46 ms 808.98 ms]
                        change: [-5.9655% -3.1128% -0.4027%] (p = 0.05 < 0.05)
                        Change within noise threshold.
bench_bounds/coconut_55/int-vec                        
                        time:   [234.33 ms 237.22 ms 239.86 ms]
                        change: [-6.0805% -4.7966% -3.6285%] (p = 0.00 < 0.05)
                        Performance has improved.

bench_memoize/gdb13_1201/no-memoize                        
                        time:   [22.327 ms 22.724 ms 23.388 ms]
                        change: [-3.0192% +5.3551% +14.669%] (p = 0.26 > 0.05)
                        No change in performance detected.
bench_memoize/gdb13_1201/frags-index                        
                        time:   [25.596 ms 25.906 ms 26.456 ms]
                        change: [-2.4206% +3.4592% +9.4365%] (p = 0.33 > 0.05)
                        No change in performance detected.
bench_memoize/gdb13_1201/nauty-index                        
                        time:   [49.883 ms 50.180 ms 50.488 ms]
                        change: [+3.6248% +4.7283% +5.7843%] (p = 0.00 < 0.05)
                        Performance has regressed.
bench_memoize/gdb13_1201/tree-nauty-index                        
                        time:   [47.280 ms 47.590 ms 47.910 ms]
                        change: [+6.0997% +7.1288% +8.1485%] (p = 0.00 < 0.05)
                        Performance has regressed.
bench_memoize/gdb17_200/no-memoize                        
                        time:   [51.625 ms 51.999 ms 52.348 ms]
                        change: [-36.733% -35.490% -34.235%] (p = 0.00 < 0.05)
                        Performance has improved.
bench_memoize/gdb17_200/frags-index                        
                        time:   [55.219 ms 55.541 ms 55.915 ms]
                        change: [-33.405% -32.121% -30.815%] (p = 0.00 < 0.05)
                        Performance has improved.
bench_memoize/gdb17_200/nauty-index                        
                        time:   [88.178 ms 88.592 ms 88.994 ms]
                        change: [-24.692% -23.838% -23.026%] (p = 0.00 < 0.05)
                        Performance has improved.
bench_memoize/gdb17_200/tree-nauty-index                        
                        time:   [76.348 ms 76.703 ms 77.047 ms]
                        change: [-28.509% -27.639% -26.762%] (p = 0.00 < 0.05)
                        Performance has improved.
bench_memoize/checks/no-memoize                        
                        time:   [11.679 ms 11.978 ms 12.274 ms]
                        change: [-2.0990% -0.0432% +2.0696%] (p = 0.97 > 0.05)
                        No change in performance detected.
bench_memoize/checks/frags-index                        
                        time:   [11.327 ms 11.412 ms 11.483 ms]
                        change: [-1.0101% +0.3051% +1.6749%] (p = 0.66 > 0.05)
                        No change in performance detected.
bench_memoize/checks/nauty-index                        
                        time:   [21.899 ms 22.180 ms 22.460 ms]
                        change: [-1.8757% +1.0243% +4.1871%] (p = 0.54 > 0.05)
                        No change in performance detected.
bench_memoize/checks/tree-nauty-index                        
                        time:   [16.007 ms 16.163 ms 16.324 ms]
                        change: [-1.0252% +0.8112% +2.6985%] (p = 0.42 > 0.05)
                        No change in performance detected.
bench_memoize/coconut_55/no-memoize                        
                        time:   [300.53 ms 310.92 ms 320.03 ms]
                        change: [-6.6146% -2.4958% +1.4217%] (p = 0.24 > 0.05)
                        No change in performance detected.
bench_memoize/coconut_55/frags-index                        
                        time:   [254.89 ms 261.93 ms 268.36 ms]
                        change: [-7.8595% -4.8567% -1.7930%] (p = 0.00 < 0.05)
                        Performance has improved.
bench_memoize/coconut_55/nauty-index                        
                        time:   [273.24 ms 275.89 ms 278.34 ms]
                        change: [-4.7965% -3.1433% -1.5129%] (p = 0.00 < 0.05)
                        Performance has improved.
bench_memoize/coconut_55/tree-nauty-index                        
                        time:   [232.61 ms 236.49 ms 240.08 ms]
                        change: [-7.0343% -5.2680% -3.4177%] (p = 0.00 < 0.05)
                        Performance has improved.

@AgentElement AgentElement requested a review from jdaymude August 4, 2025 21:32
@jdaymude
Copy link
Contributor

jdaymude commented Aug 4, 2025

Benchmarking Results for f134492 (this) vs. 7539cef (main)

The results of cargo bench --bench benchmark -- bench_canonize --baseline 7539cef --load-baseline f134492:

bench_canonize/gdb13_1201/nauty                                                                          
                        time:   [104.64 ms 104.68 ms 104.72 ms]
                        change: [-0.7522% -0.6907% -0.6252%] (p = 0.00 < 0.05)
                        Change within noise threshold.
bench_canonize/gdb13_1201/tree-nauty                                                                           
                        time:   [52.627 ms 52.705 ms 52.785 ms]
                        change: [-15.112% -14.956% -14.786%] (p = 0.00 < 0.05)
                        Performance has improved.
bench_canonize/gdb17_200/nauty                                                                          
                        time:   [2.7782 s 2.7819 s 2.7857 s]
                        change: [+5.3668% +5.4965% +5.6508%] (p = 0.00 < 0.05)
                        Performance has regressed.
bench_canonize/gdb17_200/tree-nauty                                                                          
                        time:   [1.0386 s 1.0402 s 1.0417 s]
                        change: [-15.078% -14.925% -14.788%] (p = 0.00 < 0.05)
                        Performance has improved.
bench_canonize/checks/nauty                                                                          
                        time:   [1.2724 s 1.2766 s 1.2810 s]
                        change: [+4.0984% +4.4158% +4.8083%] (p = 0.00 < 0.05)
                        Performance has regressed.
bench_canonize/checks/tree-nauty                                                                          
                        time:   [406.69 ms 406.99 ms 407.27 ms]
                        change: [-9.8070% -9.5757% -9.3654%] (p = 0.00 < 0.05)
                        Performance has improved.
bench_canonize/coconut_55/nauty                                                                          
                        time:   [11.978 s 11.988 s 11.997 s]
                        change: [-0.3465% -0.2357% -0.1383%] (p = 0.00 < 0.05)
                        Change within noise threshold.
bench_canonize/coconut_55/tree-nauty                                                                          
                        time:   [3.8617 s 3.8859 s 3.9119 s]
                        change: [-8.9870% -8.3631% -7.7245%] (p = 0.00 < 0.05)
                        Performance has improved.

CanonizeMode::TreeNauty is now roughly 8–15% faster depending on the dataset, as desired. Somewhat inexplicably, CanonizeMode::Nauty is benchmarking around 5% slower on gdb17_200 and checks even though nothing affecting that mode was changed?

Copy link
Contributor

@jdaymude jdaymude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@jdaymude jdaymude changed the title Parallel canonization Parallelize canonization Aug 4, 2025
@jdaymude jdaymude merged commit a51178c into main Aug 4, 2025
11 checks passed
@jdaymude jdaymude deleted the parallel-canon branch August 4, 2025 21:39
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