Skip to content

Cut binary size in similarity coefficients.#5455

Open
seunghwak wants to merge 4 commits intorapidsai:mainfrom
seunghwak:enh_similarity_binary_size
Open

Cut binary size in similarity coefficients.#5455
seunghwak wants to merge 4 commits intorapidsai:mainfrom
seunghwak:enh_similarity_binary_size

Conversation

@seunghwak
Copy link
Contributor

Jaccard/Sorensen/Overlap/Cosine similarity coefficients share most implementation except for the functor but they are all separately instantiated.

This refactors the code to minimize code duplication to cut libcugraph.so size (for a single architecture 434,242,184 bytes to 411,711,152 bytes).

Check that performance impact is minimal.

./gtests/SIMILARITY_TEST --gtest_filter=rmatbench3232 --perf --rmat_scale=15
Before

[==========] Running 4 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 4 tests from rmat_benchmark_test/Tests_Similarity_Rmat
[ RUN      ] rmat_benchmark_test/Tests_Similarity_Rmat.CheckInt32Int32FloatJaccard/0
Construct graph called 1 times, average time: 0.105683 s.
Similarity test called 1 times, average time: 1.77172 s.
[       OK ] rmat_benchmark_test/Tests_Similarity_Rmat.CheckInt32Int32FloatJaccard/0 (3130 ms)
[ RUN      ] rmat_benchmark_test/Tests_Similarity_Rmat.CheckInt32Int32FloatSorensen/0
Construct graph called 1 times, average time: 0.00157557 s.
Similarity test called 1 times, average time: 1.77397 s.
[       OK ] rmat_benchmark_test/Tests_Similarity_Rmat.CheckInt32Int32FloatSorensen/0 (2961 ms)
[ RUN      ] rmat_benchmark_test/Tests_Similarity_Rmat.CheckInt32Int32FloatOverlap/0
Construct graph called 1 times, average time: 0.00158208 s.
Similarity test called 1 times, average time: 1.77423 s.
[       OK ] rmat_benchmark_test/Tests_Similarity_Rmat.CheckInt32Int32FloatOverlap/0 (2960 ms)
[ RUN      ] rmat_benchmark_test/Tests_Similarity_Rmat.CheckInt32Int32FloatCosine/0
Construct graph called 1 times, average time: 0.00156846 s.
Similarity test called 1 times, average time: 1.77286 s.
[       OK ] rmat_benchmark_test/Tests_Similarity_Rmat.CheckInt32Int32FloatCosine/0 (2960 ms)
[----------] 4 tests from rmat_benchmark_test/Tests_Similarity_Rmat (12013 ms total)

[----------] Global test environment tear-down
[==========] 4 tests from 1 test suite ran. (12013 ms total)
[  PASSED  ] 4 tests.

After

[==========] Running 4 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 4 tests from rmat_benchmark_test/Tests_Similarity_Rmat
[ RUN      ] rmat_benchmark_test/Tests_Similarity_Rmat.CheckInt32Int32FloatJaccard/0
Construct graph called 1 times, average time: 0.105432 s.
Similarity test called 1 times, average time: 1.77944 s.
[       OK ] rmat_benchmark_test/Tests_Similarity_Rmat.CheckInt32Int32FloatJaccard/0 (3142 ms)
[ RUN      ] rmat_benchmark_test/Tests_Similarity_Rmat.CheckInt32Int32FloatSorensen/0
Construct graph called 1 times, average time: 0.00154222 s.
Similarity test called 1 times, average time: 1.75058 s.
[       OK ] rmat_benchmark_test/Tests_Similarity_Rmat.CheckInt32Int32FloatSorensen/0 (2933 ms)
[ RUN      ] rmat_benchmark_test/Tests_Similarity_Rmat.CheckInt32Int32FloatOverlap/0
Construct graph called 1 times, average time: 0.00153974 s.
Similarity test called 1 times, average time: 1.75471 s.
[       OK ] rmat_benchmark_test/Tests_Similarity_Rmat.CheckInt32Int32FloatOverlap/0 (2939 ms)
[ RUN      ] rmat_benchmark_test/Tests_Similarity_Rmat.CheckInt32Int32FloatCosine/0
Construct graph called 1 times, average time: 0.00155694 s.
Similarity test called 1 times, average time: 1.75514 s.
[       OK ] rmat_benchmark_test/Tests_Similarity_Rmat.CheckInt32Int32FloatCosine/0 (2939 ms)
[----------] 4 tests from rmat_benchmark_test/Tests_Similarity_Rmat (11955 ms total)

[----------] Global test environment tear-down
[==========] 4 tests from 1 test suite ran. (11955 ms total)
[  PASSED  ] 4 tests.

@seunghwak seunghwak requested review from a team as code owners March 6, 2026 04:48
@seunghwak seunghwak self-assigned this Mar 6, 2026
@seunghwak seunghwak added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement / enhancement to an existing function non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant